From patchwork Fri Oct 11 04:27:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1174946 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46qFLq2MPZz9sP3 for ; Fri, 11 Oct 2019 15:28:19 +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="E3xtAvm0"; 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 46qFLn1zPJzDqWh for ; Fri, 11 Oct 2019 15:28:17 +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=oohall@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="E3xtAvm0"; 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 46qFLY004CzDqWN for ; Fri, 11 Oct 2019 15:28:02 +1100 (AEDT) Received: by mail-pf1-x444.google.com with SMTP id q21so5262950pfn.11 for ; Thu, 10 Oct 2019 21:28:02 -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:mime-version :content-transfer-encoding; bh=xYvue0GP+YRREdheG4TzIdR74gZM+Oi0nuy2jBGrGH8=; b=E3xtAvm0Xdx68ZyEnBM/zWCH4wig0f2+LgHQsEpxnqzUMejIjMpzKOMh6nl3CwE070 o6JdZdY3mR0crkKcyNmp6bwgT+FkW4i/DrDQQgGHQIbUbBwWi6VLtvNl2dyS6mcUQqSl cObuFceCIRJIEdCpRrmOW5etHuUL1VLq5vgHSI0QD1pSE2jQLDxl4nmp+yBMClTQCVko aSXgeGy4Qr7a1wrrxAx7Zm3Z46/Bhkxs7DTtJ7lD5KqtgcD4vyJDBYQSjyns8RGKRC1i XvfO2m63T/9e/tTa149UpPcFFl6bH2JQ1LeYyRvITQIwlWwR0SB40eTYxfeaXH26b9vR Wc+Q== 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:mime-version :content-transfer-encoding; bh=xYvue0GP+YRREdheG4TzIdR74gZM+Oi0nuy2jBGrGH8=; b=o6LSZxgyypm52A6B83UCF2vKRrftDHc0bKI5NcxWxu3nvLVI0Rp9fF7kSEkO6tTJer Jw4uUcQ+uBvNsyD4EuMdYFtUiyN7d0Y0dtZM92HaRWrCIxD9BcLqODRc7AYdYd20ZZKx XJ/BMB/bc5giTveDM/a4l7b6ZsWE5ibP56NGwNUoa6hLlFVrWbtKYr8HaJ+smPvofXwk vh7oC/oMC+kdhCsek3O5LNwKBAmouy3LSSng46eHlcj513aQn3DyG8qz4y37mFuq6jZ2 W7jmRboUxsHyhVsOvAafLo26S3i5ecBvrnIBFp3dZPe8ZTdhV+HLTY0rhddu2yvZrbcz ySQg== X-Gm-Message-State: APjAAAWOw81ZmGR2g3/1UTUdhErNtb2AtjR1hTfoV+SkYDK8KwM6t3lQ D1siA+i5GnKsyZa+evfEeNazl1L0 X-Google-Smtp-Source: APXvYqz31zw749KxP65ConegbAHqTe6j4c0naXHWTHUQTMFUwAWvBRLCP7oAxeW71CxSY0UjqDNqNg== X-Received: by 2002:aa7:8dd9:: with SMTP id j25mr12179597pfr.94.1570768075161; Thu, 10 Oct 2019 21:27:55 -0700 (PDT) Received: from wafer.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i190sm9500856pgc.93.2019.10.10.21.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 21:27:54 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 11 Oct 2019 15:27:41 +1100 Message-Id: <20191011042742.2555-1-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Skiboot] [PATCH 1/2] core/init: Don't checksum MPIPL data areas 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" Right now the romem checksum runs from _start until the start of our data area. This spans the area used for the MPIPL data structures since they're included in the SPIRA-H data area. Cc: Vasant Hegde Signed-off-by: Oliver O'Halloran Reviewed-by: Vasant Hegde --- We might be able to move the MPIPL tables to after the .rodata section in the linker script. --- core/init.c | 6 +++++- include/skiboot.h | 1 + skiboot.lds.S | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/init.c b/core/init.c index 62d9c709fac9..c2d7324622db 100644 --- a/core/init.c +++ b/core/init.c @@ -927,8 +927,12 @@ static void checksum_romem(void) if (chip_quirk(QUIRK_SLOW_SIM)) return; - csum = mem_csum(_start, _romem_end); + csum = mem_csum(_start, _head_end); romem_csum ^= csum; + + csum = mem_csum(_stext, _romem_end); + romem_csum ^= csum; + csum = mem_csum(__builtin_kernel_start, __builtin_kernel_end); romem_csum ^= csum; } diff --git a/include/skiboot.h b/include/skiboot.h index 686ba9dc8411..10b43e8c37f8 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -37,6 +37,7 @@ extern struct mem_region *mem_region_next(struct mem_region *region); /* Misc linker script symbols */ extern char _start[]; +extern char _head_end[]; extern char _stext[]; extern char _etext[]; extern char __sym_map_end[]; diff --git a/skiboot.lds.S b/skiboot.lds.S index 8890d69aa804..32139b2c5b7f 100644 --- a/skiboot.lds.S +++ b/skiboot.lds.S @@ -69,6 +69,13 @@ SECTIONS KEEP(*(.spirah.data)) } + _head_end = .; + + /* + * The following sections are read-write at runtime. We need + * to skip over them when checksumming the skiboot images + * before a fast-reboot. + */ . = PROC_DUMP_AREA_OFF; .procdump : { KEEP(*(.procdump.data)) @@ -94,6 +101,8 @@ SECTIONS KEEP(*(.cpuctrl.data)) } + /* ...and back to RO */ + . = ALIGN(0x10); _stext = .; .text : { From patchwork Fri Oct 11 04:27:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1174947 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 46qFM336fDz9sP3 for ; Fri, 11 Oct 2019 15:28:31 +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="MpbIEBQe"; 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 46qFM31m55zDqWj for ; Fri, 11 Oct 2019 15:28:31 +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::542; helo=mail-pg1-x542.google.com; envelope-from=oohall@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="MpbIEBQe"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 46qFLY04nQzDqWR for ; Fri, 11 Oct 2019 15:28:02 +1100 (AEDT) Received: by mail-pg1-x542.google.com with SMTP id b8so4999451pgm.13 for ; Thu, 10 Oct 2019 21:28:02 -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=pTT5groydm0MW/jUqMawrbGza3p74W2OYw5RnQuiPUA=; b=MpbIEBQekC8OdyaymE8IZK5hDglN7TjS6YJaV0NI3E8GVD3vb59lMqQdIwkjIlyivo PyXkUKV6M+v78YC41F0A8T9kB60Iu4qJcROMcrbYBn8NhcykOVlljHSAwFuQt1GrWVU8 bWjywUpSets4eXdVw5qj65wBdTI3+jKF2xNkY5n8LWF7dmjV8jHeXrsJJBCZfpFDH3nH 1MY78uxNu6lKq5mS4NC0YdVroGBJhVoVA11r6OHHv1swq7dIAxALymqv06hEtPI42kkt cVex+p+y3HdGNC+1saGzS/hpxddiME+YVssX3Uw+m4ksdyuuzwKA/fiATMvsMW7cKUf0 W1Wg== 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=pTT5groydm0MW/jUqMawrbGza3p74W2OYw5RnQuiPUA=; b=cNqHbnlz6XViJxl0aIPT0+tAcD6GqZhlBrtere7d7Ulqi+7CErLx0BeMg0vgfmq6B8 MGvxFQ28DXeayQwLPRlkk+6E17VP886l1kT5RPqxpAtZ0EMrD5SoWym3SqT83ZxJ02kB 9P0XP8JeRPG1tnHqbfoBgr7p0rdWXwoODnU9/vJR2KV65UFkTh1Bzp56/H6yIpj6d89x mylmRCVHT4xExQtfrPUaMyR2IphLyp/zC1Mazuc2FMVj1hJe12nh/vQoNVbhznZor3bH /kGAEi3tHfsp28jk+5cGKGqq/T5JS+iH21dSuxXV532hSbTG7qj44cbaSAdqDO7L5iam DQng== X-Gm-Message-State: APjAAAXCjJjW8EpRWXDHio+yOMhR5zfJpVDseYgShwY1tQ27pQqTpr5M L+s1Dkp4VwO19sk18iXHEYuHpPtI X-Google-Smtp-Source: APXvYqzhuSzbYdVK0LcxqSjSNC9g/+SwaHuvymL13KV2p2XVYZAsOWZnRZVuBqu+feCRNg96T+2dwA== X-Received: by 2002:a65:5c45:: with SMTP id v5mr14290462pgr.82.1570768077257; Thu, 10 Oct 2019 21:27:57 -0700 (PDT) Received: from wafer.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i190sm9500856pgc.93.2019.10.10.21.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 21:27:56 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 11 Oct 2019 15:27:42 +1100 Message-Id: <20191011042742.2555-2-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191011042742.2555-1-oohall@gmail.com> References: <20191011042742.2555-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 2/2] core/init: Checksum romem after patching out traps 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: , Cc: Carol L Soto Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Currently we checksum the read-only parts of skiboot's memory just before loading and booting petitboot. Commit 9ddc1a6bfaef ("core/util: trap based assertions") modifies the .text after this point since it needs to disable the trap instructions that we use to trigger an abort() before entering the kernel. We can fix this by moving the checksum to after the point where the traps are patched out. We could do the patching sooner, but since load_and_boot_kernel() is a fairly complex function it's perferable to keep boot-time assertion infrastructure active until just before we enter the kernel. Reported-by: Carol L Soto Fixes: 9ddc1a6bfaef ("core/util: trap based assertions") Signed-off-by: Oliver O'Halloran Tested-by: Vasant Hegde Tested-by: Carol L Soto --- core/init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/init.c b/core/init.c index c2d7324622db..cc1fdbc4d0b0 100644 --- a/core/init.c +++ b/core/init.c @@ -85,6 +85,8 @@ struct debug_descriptor debug_descriptor = { #endif }; +static void checksum_romem(void); + static bool try_load_elf64_le(struct elf_hdr *header) { struct elf64_hdr *kh = (struct elf64_hdr *)header; @@ -621,6 +623,8 @@ void __noreturn load_and_boot_kernel(bool is_reboot) patch_traps(false); + checksum_romem(); + debug_descriptor.state_flags |= OPAL_BOOT_COMPLETE; cpu_give_self_os(); @@ -1320,8 +1324,6 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) prd_register_reserved_memory(); - checksum_romem(); - load_and_boot_kernel(false); }