From patchwork Tue Oct 15 03:06:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1176736 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 46sgXS6FGgz9sPJ for ; Tue, 15 Oct 2019 14:15:04 +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="Hgnvql/2"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46sgXS4MtfzDqR5 for ; Tue, 15 Oct 2019 14:15:04 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.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="Hgnvql/2"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (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 46sgTH73b3zDqx4 for ; Tue, 15 Oct 2019 14:12:19 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id a2so11492320pfo.10 for ; Mon, 14 Oct 2019 20:12:19 -0700 (PDT) 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=hvyaWYrbKrX3ZdB/WujLKyZwc8SRQPOa323XIHoubgE=; b=Hgnvql/2aCDW76dafkklEaIWvOxUQdb/3sUDOVwczWsKBuawOYEFqfwzHWLZEAQiuB tdCV7gESLWX3w9T/wzo3R8XPcMkWAu+JexLdqQZgrF0uLD+7+/EDYFEDcwHSUyB46+g/ 9jQsyGG+roH25DvhPvFF8mp8zZYpib3KU9GZyqB9GwO3uaQDXD9VerqKJ7n1BOCBlCvo +wMbhi2xl7RcNuxxPu4PCV9akuSge3lnLSDsAxkqMwz/E+6+dkwD+Su8PVrCnlV0vepE HmuwVaoKaouYbV6EFJFBP1jgtii6jhW17QvZiP7juAiLEa7J9heNMjaY52tFq75eBXwP jM5Q== 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=hvyaWYrbKrX3ZdB/WujLKyZwc8SRQPOa323XIHoubgE=; b=WxYy/78uTdP+OkcS2vvUyEPQwF7LwPhXET4oHHfDuUJgvXrXPcqqjQ7vC0Wl8+T9yk KjCmN7reEsSKkkxzyluoK53ezozVDTpqfG/gbIS7BKois4Wul6scjrsxLsR7NkL/6mmm 3RvUiY4Lh0jtXFg2Rw6aDA4GYPta6lMLz8k/I8BKEdaCeA72yTxYfQIHTRmDdKOv0F7y hi3Wxx55FqO3xygt+YwvGkFMw82nHClxUVatgkNn+C82RBdEIsbIaxK1TH4+/LiqVf/3 MB0lbQjJhPSCB3wQ52moDZgTwYR7aBkj3RmM40gaUrSCOjAIJ7kvzkZbTcEp8lkQJjRl XxWQ== X-Gm-Message-State: APjAAAUBpf5idsH/7yIMn7Smz1bG7soEVl8pFjaNBL8s0CyxZAGTvm7u al3AUGGXCzmfGE0sYpOoEQRoauTK5YA= X-Google-Smtp-Source: APXvYqz54PyrGr4kOgc/j0DqkMCn4FDAgG+ANokg2PwYOzpjBHUjfx4UfVTk5CETJtiG7hqK5Yr4hg== X-Received: by 2002:a17:90a:8c14:: with SMTP id a20mr40105204pjo.77.1571109137228; Mon, 14 Oct 2019 20:12:17 -0700 (PDT) Received: from bobo.local0.net (60-240-111-58.tpgi.com.au. [60.240.111.58]) by smtp.gmail.com with ESMTPSA id w6sm23089828pfw.84.2019.10.14.20.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 20:12:16 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Tue, 15 Oct 2019 13:06:57 +1000 Message-Id: <20191015030717.15637-8-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191015030717.15637-1-npiggin@gmail.com> References: <20191015030717.15637-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v5 07/27] 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 --- hdata/spira.c | 55 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/hdata/spira.c b/hdata/spira.c index 5e73b7d44..f1ce25dff 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)),