From patchwork Sun Dec 8 12:22:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1205621 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 47W5Fh4QkBz9sP3 for ; Sun, 8 Dec 2019 23:28:08 +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="YAVUUiI5"; 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 47W5Fh38dDzDqJH for ; Sun, 8 Dec 2019 23:28:08 +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::642; helo=mail-pl1-x642.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="YAVUUiI5"; dkim-atps=neutral Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (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 47W58V3YTQzDqDV for ; Sun, 8 Dec 2019 23:23:38 +1100 (AEDT) Received: by mail-pl1-x642.google.com with SMTP id x13so4608693plr.9 for ; Sun, 08 Dec 2019 04:23:38 -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=4hjunjg3NXZ2G2IfHTctnTs2v7nQufULBIOgtvrJVaM=; b=YAVUUiI5MojmK/XvEOy1HFNg9b8jWkftjl+st/ugYsE7jv5TLKLmx2JLrSdgnTT96O Kzov0tG4gmdETG0aDfOi2JBieYXbX8O+z4eWCMk9pAash08HGhxgffezpEpakCriYTFM ulTknqh6fVhMR/3yrk6UnkYYE6fY8fvDRxBAFI2d+SpNMkcI8ID+uPXptJ+/58oB9hB/ DMvbkj3GM62DimCZwYZmI6OCoewYtb1GoBOX55hTWi3vC5FRecy+N+4cpyn5stXbfO8L 8fthizmMTswQzRm/qSJsUu+kJLhCfdArEa5k6JXmXyVL+oBQ4zxiHZ8OL+D6n/X6ofsy pYoA== 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=4hjunjg3NXZ2G2IfHTctnTs2v7nQufULBIOgtvrJVaM=; b=l8cZXVvfFmyqpmrEyhuIZNT8osy44Vnuw+42Dx4zI+IpxfPHUuG8g5M+BXzINALCIB KpPVjCul1wTIhZ7ym9W06TBARvvpEDwSvMFPdn9rbYJ16EK3flKTtmW2cqFAd+PT5aW1 X8sjtXg4YgQvcTDsWK3RdXFswyHHwd6lrO1EWPrUnNhzS4Y8GhiDNTuOVHX9k9Tgocss AfEQaHLAWeW1PWZ+1b3p0zdx0y9djYiPMlLdeCBfeufV7has8o+Oh2WzqY2N4EKlZtXU 7Fto4CjthjVZM815HRxIM2E1/xmBBoGY3NBxOL7i4rCt0G5UkKd4uDHQCxl8gL3Kx8p5 80zA== X-Gm-Message-State: APjAAAWSkBQth0LCh/i+JbtC0lq9sTbc7Nh01XJ3TOnwKp6SDpTzLEGJ 6hED0qhCvuiLTHG79QCLnJCvT5bL X-Google-Smtp-Source: APXvYqzThGtJRnEFmt+qlOq3k5hCcrw26ZLDzrRihS7/NYjrPIbvq/N0Q0Oj0FyYpNAkBidq4GCGBQ== X-Received: by 2002:a17:90a:f0d6:: with SMTP id fa22mr26428169pjb.136.1575807815924; Sun, 08 Dec 2019 04:23:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2019 04:23:35 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 8 Dec 2019 22:22:48 +1000 Message-Id: <20191208122312.12837-8-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 07/31] spira: fix endian conversions in spira data structures 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" Labels can't be used for static initialisers that require endian conversion. Use constants for these. Signed-off-by: Nicholas Piggin Reviewed-by: Vasant Hegde --- hdata/spira.c | 59 +++++++++++++++++++++++++--------------- hdata/test/hdata_to_dt.c | 3 ++ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/hdata/spira.c b/hdata/spira.c index 6e4da3c02..2d0e875e3 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -33,41 +33,61 @@ __section(".procin.data") struct proc_init_data proc_init_data = { .regs_ptr = HDIF_IDATA_PTR(offsetof(struct proc_init_data, regs), 0x10), .regs = { .nia = CPU_TO_BE64(0x180), - .msr = CPU_TO_BE64(0x9000000000000000ULL), /* SF | HV */ + .msr = CPU_TO_BE64(MSR_SF | MSR_HV), }, }; +extern struct cpu_ctl_init_data cpu_ctl_init_data; extern struct sp_addr_table cpu_ctl_spat_area; -__section(".cpuctrl.data") struct sp_addr_table cpu_ctl_spat_area; -__section(".cpuctrl.data") struct sp_attn_area cpu_ctl_sp_attn_area1; -__section(".cpuctrl.data") struct sp_attn_area cpu_ctl_sp_attn_area2; +extern struct sp_attn_area cpu_ctl_sp_attn_area1; +extern struct sp_attn_area cpu_ctl_sp_attn_area2; extern struct hsr_data_area cpu_ctl_hsr_area; + +/* + * cpuctrl.data begins at CPU_CTL_OFF - cpu_ctl_init_data is located there. + * + sizeof(struct cpu_ctl_init_data) - cpu_ctl_spat_area + * + sizeof(struct sp_addr_table) - cpu_ctl_sp_attn_area1 + * + sizeof(struct sp_attn_area) - cpu_ctl_sp_attn_area2 + * + sizeof(struct sp_attn_area) - cpu_ctl_hsr_area + * + * Can't use CPU_TO_BE64 directly on the labels as a constant initialiser. + * + * CPU_CTL_INIT_DATA_OFF is offset from 0, the others are addressed from the + * relocated address (+SKIBOOT_BASE) + */ +#define CPU_CTL_INIT_DATA_OFF (CPU_CTL_OFF) +#define CPU_CTL_SPAT_AREA_OFF (CPU_CTL_INIT_DATA_OFF + sizeof(struct cpu_ctl_init_data) + SKIBOOT_BASE) +#define CPU_CTL_SP_ATTN_AREA1_OFF (CPU_CTL_SPAT_AREA_OFF + sizeof(struct sp_addr_table)) +#define CPU_CTL_SP_ATTN_AREA2_OFF (CPU_CTL_SP_ATTN_AREA1_OFF + sizeof(struct sp_attn_area)) +#define CPU_CTL_HSR_AREA_OFF (CPU_CTL_SP_ATTN_AREA2_OFF + sizeof(struct sp_attn_area)) + __section(".cpuctrl.data") struct hsr_data_area cpu_ctl_hsr_area; +__section(".cpuctrl.data") struct sp_attn_area cpu_ctl_sp_attn_area2; +__section(".cpuctrl.data") struct sp_attn_area cpu_ctl_sp_attn_area1; +__section(".cpuctrl.data") struct sp_addr_table cpu_ctl_spat_area; -extern struct cpu_ctl_init_data cpu_ctl_init_data; __section(".cpuctrl.data") struct cpu_ctl_init_data cpu_ctl_init_data = { .hdr = HDIF_SIMPLE_HDR(CPU_CTL_HDIF_SIG, 2, struct cpu_ctl_init_data), - .cpu_ctl = HDIF_IDATA_PTR(offsetof(struct cpu_ctl_init_data, cpu_ctl_lt), sizeof(struct cpu_ctl_legacy_table)), -#if !defined(TEST) + .cpu_ctl = HDIF_IDATA_PTR(offsetof(struct cpu_ctl_init_data, cpu_ctl_lt), + sizeof(struct cpu_ctl_legacy_table)), .cpu_ctl_lt = { .spat = { - .addr = CPU_TO_BE64((unsigned long)&(cpu_ctl_spat_area) + SKIBOOT_BASE), + .addr = CPU_TO_BE64(CPU_CTL_SPAT_AREA_OFF), .size = CPU_TO_BE64(sizeof(struct sp_addr_table)), }, .sp_attn_area1 = { - .addr = CPU_TO_BE64((unsigned long)&(cpu_ctl_sp_attn_area1) + SKIBOOT_BASE), + .addr = CPU_TO_BE64(CPU_CTL_SP_ATTN_AREA1_OFF), .size = CPU_TO_BE64(sizeof(struct sp_attn_area)), }, .sp_attn_area2 = { - .addr = CPU_TO_BE64((unsigned long)&(cpu_ctl_sp_attn_area2) + SKIBOOT_BASE), + .addr = CPU_TO_BE64(CPU_CTL_SP_ATTN_AREA2_OFF), .size = CPU_TO_BE64(sizeof(struct sp_attn_area)), }, .hsr_area = { - .addr = CPU_TO_BE64((unsigned long)&(cpu_ctl_hsr_area) + SKIBOOT_BASE), + .addr = CPU_TO_BE64(CPU_CTL_HSR_AREA_OFF), .size = CPU_TO_BE64(sizeof(struct hsr_data_area)), }, }, -#endif }; /* Populate MDST table @@ -131,15 +151,12 @@ __section(".spira.data") struct spira spira = { .alloc_len = CPU_TO_BE32(sizeof(init_mdst_table)), }, -#if !defined(TEST) .cpu_ctrl = { - .addr = CPU_TO_BE64((unsigned long)&cpu_ctl_init_data), + .addr = CPU_TO_BE64(CPU_CTL_INIT_DATA_OFF), .alloc_cnt = CPU_TO_BE16(1), .act_cnt = CPU_TO_BE16(1), - .alloc_len = - CPU_TO_BE32(sizeof(cpu_ctl_init_data)), + .alloc_len = CPU_TO_BE32(sizeof(cpu_ctl_init_data)), }, -#endif }, }; @@ -170,15 +187,13 @@ __section(".spirah.data") struct spirah spirah = { .alloc_len = CPU_TO_BE32(sizeof(struct proc_init_data)), }, -#if !defined(TEST) .cpu_ctrl = { - .addr = CPU_TO_BE64((unsigned long)&cpu_ctl_init_data), + .addr = CPU_TO_BE64(CPU_CTL_INIT_DATA_OFF), .alloc_cnt = CPU_TO_BE16(1), .act_cnt = CPU_TO_BE16(1), .alloc_len = CPU_TO_BE32(sizeof(cpu_ctl_init_data)), }, -#endif .mdump_src = { .addr = CPU_TO_BE64(MDST_TABLE_OFF), .alloc_cnt = CPU_TO_BE16(MDST_TABLE_SIZE / sizeof(struct mdst_table)), @@ -1695,8 +1710,8 @@ static void update_spirah_addr(void) if (proc_gen < proc_gen_p9) return; - *spirah_offset = SPIRAH_OFF; - *spira_offset = SPIRA_OFF; + *spirah_offset = CPU_TO_BE64(SPIRAH_OFF); + *spira_offset = 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/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c index 4605d507e..11b7a3aca 100644 --- a/hdata/test/hdata_to_dt.c +++ b/hdata/test/hdata_to_dt.c @@ -67,6 +67,9 @@ unsigned long tb_hz = 512000000; #define SPR_PVR 0x11f /* RO: Processor version register */ +#define MSR_SF 0x8000000000000000ULL +#define MSR_HV 0x1000000000000000ULL + #define __CPU_H struct cpu_thread { uint32_t pir;