From patchwork Sun Dec 8 12:22:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1205625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W5Gc6YY4z9sPL for ; Sun, 8 Dec 2019 23:28:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Gx2N/BiA"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47W5Gc4t4pzDqFG for ; Sun, 8 Dec 2019 23:28:56 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Gx2N/BiA"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47W58d0DPyzDqP1 for ; Sun, 8 Dec 2019 23:23:45 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id bd4so4609792plb.8 for ; Sun, 08 Dec 2019 04:23:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uTtjqdDqUVQYvpfq9YjDER1OXrAR1H0VJS0uzzjs0M4=; b=Gx2N/BiAosfwQUAw++l7L1cyDR1YQhTTYphchLmMPilGybczolgDuhz9HJlgGg8rgo B+yKvGiOvyWne33y/1dELmIarTm7cFLPMOmFDNLGNG5am8Zc89jJ+360IDgNA3eB6pJ5 wyQPDNF+xz1mlgrL5ik3X2lYdX3ksKlYtzF5ujYIiHfSKtGzemxbM3yiRyMETsV/Gozm c36ApybFkpHarXLwtU9xgxQo2ovm/GuonHpyzPGhN4GH54nOsy3OqOtkgP0Uf0YpQ1c1 E+cCWXeW936niC7PfV5q5d2985vsjY13vOvcyW0MiEguGpR8xNit5oOElTrSxRcMYplW O55Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uTtjqdDqUVQYvpfq9YjDER1OXrAR1H0VJS0uzzjs0M4=; b=DtZ8L9y2TlbB/3J6oqRM5dLH93UmSbEEahBb3R71FB+YOysCDVAIbWbsU4aGIVwPvW R8iwd/5LUB8oCqABc9PGSSpY9tszerGg5M4ylttLF96ZY7PYyW7dt+k86MvAgWzSi+Zr VlRHjzKgyfbkc+sAZaXAXpuxO9YQ9Qgf6d+dt+n3nyJgwyzZQG0JbViQsJm7l4aPPoez WpFo9dACVt1lb3t9VtK+55UG2ZKrcOpcX3M19s6rowkQBvf2kr7u7fHGLbNHPfm28SVW mZNZwbJuXzRnd2ZljZqZXxm2jf80LFv2qSi4qXBSqFgw8ly02Ba7qEOMfPw8icyccKrt HsVQ== X-Gm-Message-State: APjAAAWkwcajLN/arNvlBJv+O97CjIEdK+I/fBQGcLhBe47fEqEznFSF 3zTSxm/waTFx7nOJhQ8YtwhSW5tg X-Google-Smtp-Source: APXvYqxcG3cfBncgVa78SpLAhdZP2hw31I99H9pSR8Ov7yeW6TiyfRCLbtVW9z1QfNV2zFZhj9PVwA== X-Received: by 2002:a17:90a:b318:: with SMTP id d24mr25378067pjr.142.1575807822833; Sun, 08 Dec 2019 04:23:42 -0800 (PST) Received: from bobo.local0.net ([202.21.15.182]) by smtp.gmail.com with ESMTPSA id i9sm23741866pfk.24.2019.12.08.04.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2019 04:23:42 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 8 Dec 2019 22:22:50 +1000 Message-Id: <20191208122312.12837-10-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191208122312.12837-1-npiggin@gmail.com> References: <20191208122312.12837-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v10 09/31] naca: move naca definition from asm to C X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This results in the same layout and location of the naca and hv data structures. Signed-off-by: Nicholas Piggin --- asm/asm-offsets.c | 2 -- asm/head.S | 50 ------------------------------------------ hdata/Makefile.inc | 2 +- hdata/hdata.h | 2 ++ hdata/naca.c | 26 ++++++++++++++++++++++ hdata/naca.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++ hdata/spira.c | 11 ++++------ hdata/spira.h | 6 +++++- include/mem-map.h | 2 ++ skiboot.lds.S | 5 +++++ 10 files changed, 99 insertions(+), 61 deletions(-) create mode 100644 hdata/naca.c create mode 100644 hdata/naca.h diff --git a/asm/asm-offsets.c b/asm/asm-offsets.c index e4584059c..61a25cab3 100644 --- a/asm/asm-offsets.c +++ b/asm/asm-offsets.c @@ -25,8 +25,6 @@ int main(void); int main(void) { - OFFSET(SPIRA_ACTUAL_SIZE, spira, reserved); - OFFSET(CPUTHREAD_PIR, cpu_thread, pir); OFFSET(CPUTHREAD_SAVE_R1, cpu_thread, save_r1); OFFSET(CPUTHREAD_STATE, cpu_thread, state); diff --git a/asm/head.S b/asm/head.S index e59f63871..b38cc870b 100644 --- a/asm/head.S +++ b/asm/head.S @@ -810,56 +810,6 @@ enter_nap: bne 1b nap b . -/* - * - * NACA structure, accessed by the FPS to find the SPIRA - * - */ - . = 0x4000 -.global naca -naca: - .llong spirah /* 0x0000 : SPIRA-H */ - .llong 0 /* 0x0008 : Reserved */ - .llong 0 /* 0x0010 : Reserved */ - .llong hv_release_data /* 0x0018 : HV release data */ - .llong 0 /* 0x0020 : Reserved */ - .llong 0 /* 0x0028 : Reserved */ - .llong spira /* 0x0030 : SP Interface Root */ - .llong hv_lid_load_table /* 0x0038 : LID load table */ - .llong 0 /* 0x0040 : Reserved */ - .space 68 - .long 0 /* 0x008c : Reserved */ - .space 16 - .long SPIRA_ACTUAL_SIZE /* 0x00a0 : Actual size of SPIRA */ - .space 28 - .llong 0 /* 0x00c0 : resident module loadmap */ - .space 136 - .llong 0 /* 0x0150 : reserved */ - .space 40 - .llong 0 /* 0x0180 : reserved */ - .space 36 - .long 0 /* 0x01ac : control flags */ - .byte 0 /* 0x01b0 : reserved */ - .space 4 - .byte 0 /* 0x01b5 : default state for SW attn */ - .space 1 - .byte 0x01 /* 0x01b7 : PCIA format */ - .llong hdat_entry /* 0x01b8 : Primary thread entry */ - .llong hdat_entry /* 0x01c0 : Secondary thread entry */ - .space 0xe38 - - .balign 0x10 -hv_release_data: - .space 58 - .llong 0x666 /* VRM ? */ - - .balign 0x10 -hv_lid_load_table: - .long 0x10 - .long 0x10 - .long 0 - .long 0 - /* * diff --git a/hdata/Makefile.inc b/hdata/Makefile.inc index 2d52f7654..49690f3c5 100644 --- a/hdata/Makefile.inc +++ b/hdata/Makefile.inc @@ -1,7 +1,7 @@ # -*-Makefile-*- SUBDIRS += hdata -HDATA_OBJS = spira.o pcia.o hdif.o memory.o fsp.o iohub.o vpd.o slca.o +HDATA_OBJS = naca.o spira.o pcia.o hdif.o memory.o fsp.o iohub.o vpd.o slca.o HDATA_OBJS += cpu-common.o vpd-common.o hostservices.o i2c.o tpmrel.o DEVSRC_OBJ = hdata/built-in.a diff --git a/hdata/hdata.h b/hdata/hdata.h index 7504b1e8f..580e5c75b 100644 --- a/hdata/hdata.h +++ b/hdata/hdata.h @@ -5,6 +5,8 @@ #define __HDATA_H #include +#include "hdif.h" +#include "spira.h" struct dt_node; diff --git a/hdata/naca.c b/hdata/naca.c new file mode 100644 index 000000000..b215c39eb --- /dev/null +++ b/hdata/naca.c @@ -0,0 +1,26 @@ +#include +#include +#include + +#include "naca.h" +#include "spira.h" + +__section(".naca.data") struct naca naca = { + .spirah_addr = CPU_TO_BE64(SPIRAH_OFF), + .hv_release_data_addr = CPU_TO_BE64(NACA_OFF + offsetof(struct naca, hv_release_data)), + .spira_addr = CPU_TO_BE64(SPIRA_OFF), + .lid_table_addr = CPU_TO_BE64(NACA_OFF + offsetof(struct naca, hv_lid_load_table)), + .spira_size = CPU_TO_BE32(SPIRA_ACTUAL_SIZE), + .hv_load_map_addr = 0, + .attn_enabled = 0, + .pcia_supported = 1, + .__primary_thread_entry = CPU_TO_BE64(0x180), + .__secondary_thread_entry = CPU_TO_BE64(0x180), + .hv_release_data = { + .vrm = CPU_TO_BE64(0x666), /* ? */ + }, + .hv_lid_load_table = { + .w0 = CPU_TO_BE32(0x10), + .w1 = CPU_TO_BE32(0x10), + }, +}; diff --git a/hdata/naca.h b/hdata/naca.h new file mode 100644 index 000000000..1271b59a5 --- /dev/null +++ b/hdata/naca.h @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: Apache-2.0 +/* Copyright 2019 IBM Corp. */ + +#ifndef __NACA_H +#define __NACA_H + +#include +#include +#include + +struct hv_release_data { + uint8_t reserved_0x0[58]; + __be64 vrm; +} __packed __attribute__((aligned(0x10))); + +struct hv_lid_load_table { + __be32 w0; + __be32 w1; + __be32 w2; + __be32 w3; +} __packed __attribute__((aligned(0x10))); + +/* + * NACA structure, accessed by the FSP to find the SPIRA + */ +struct naca { + __be64 spirah_addr; /* 0x0000 */ + uint8_t reserved_0x8[0x10]; + __be64 hv_release_data_addr; /* 0x0018 */ + uint8_t reserved_0x20[0x10]; + __be64 spira_addr; /* 0x0030 */ + __be64 lid_table_addr; /* 0x0038 */ + uint8_t reserved_0x40[0x60]; + __be32 spira_size; /* 0x00a0 */ + uint8_t reserved_0xa4[0x1c]; + __be64 hv_load_map_addr; /* 0x00c0 */ + uint8_t reserved_0xc8[0xe4]; + uint8_t flags[4]; /* 0x01ac */ + uint8_t reserved_0x1b0[0x5]; + uint8_t attn_enabled; /* 0x01b5 */ + uint8_t reserved_0x1b6[0x1]; + uint8_t pcia_supported; /* 0x01b7 */ + __be64 __primary_thread_entry; /* 0x01b8 */ + __be64 __secondary_thread_entry; /* 0x01c0 */ + uint8_t reserved_0x1d0[0xe38]; + + /* Not part of the naca but it's convenient to put them here */ + struct hv_release_data hv_release_data; + struct hv_lid_load_table hv_lid_load_table; +} __packed __attribute((aligned(0x10))); + +extern struct naca naca; + +#endif diff --git a/hdata/spira.c b/hdata/spira.c index f62170710..7e19d3d5c 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -3,7 +3,6 @@ #include #include -#include "spira.h" #include #include #include @@ -15,6 +14,8 @@ #include "hdata.h" #include "hostservices.h" +#include "naca.h" +#include "spira.h" /* Processor Initialization structure, contains * the initial NIA and MSR values for the entry @@ -1703,15 +1704,11 @@ static void fixup_spira(void) static void update_spirah_addr(void) { #if !defined(TEST) - extern uint32_t naca; - uint64_t *spirah_offset = (uint64_t *)&naca; - uint64_t *spira_offset = (uint64_t *)((u64)(&naca) + 0x30); - if (proc_gen < proc_gen_p9) return; - *spirah_offset = CPU_TO_BE64(SPIRAH_OFF); - *spira_offset = CPU_TO_BE64(SPIRA_OFF); + naca.spirah_addr = CPU_TO_BE64(SPIRAH_OFF); + naca.spira_addr = CPU_TO_BE64(SPIRA_OFF); spirah.ntuples.hs_data_area.addr = CPU_TO_BE64(SPIRA_HEAP_BASE - SKIBOOT_BASE); spirah.ntuples.mdump_res.addr = CPU_TO_BE64(MDRT_TABLE_BASE - SKIBOOT_BASE); #endif diff --git a/hdata/spira.h b/hdata/spira.h index 2c944be9f..2c2872260 100644 --- a/hdata/spira.h +++ b/hdata/spira.h @@ -66,6 +66,8 @@ struct spira_ntuples { struct spira_ntuple proc_dump_area; /* 0x400 */ }; +#define SPIRA_RESERVED_BYTES 0x60 + struct spira { struct HDIF_common_hdr hdr; struct HDIF_idata_ptr ntuples_ptr; @@ -77,9 +79,11 @@ struct spira { * * According to FSP engineers, this is an okay thing to do. */ - u8 reserved[0x60]; + u8 reserved[SPIRA_RESERVED_BYTES]; } __packed __align(0x100); +#define SPIRA_ACTUAL_SIZE (sizeof(struct spira) - SPIRA_RESERVED_BYTES) + extern struct spira spira; /* SPIRA-H signature */ diff --git a/include/mem-map.h b/include/mem-map.h index 61ecac3c8..8ac11e916 100644 --- a/include/mem-map.h +++ b/include/mem-map.h @@ -21,6 +21,8 @@ */ #define EXCEPTION_VECTORS_END 0x2000 +#define NACA_OFF 0x4000 + /* The NACA and other stuff in head.S need to be at the start: we * give it 64k before placing the SPIRA and related data. */ diff --git a/skiboot.lds.S b/skiboot.lds.S index 1dc0ca92e..1822334b2 100644 --- a/skiboot.lds.S +++ b/skiboot.lds.S @@ -59,6 +59,11 @@ SECTIONS KEEP(*(.head)) } + . = NACA_OFF; + .naca : { + KEEP(*(.naca.data)) + } + . = SPIRA_OFF; .spira : { KEEP(*(.spira.data))