From nobody Tue May 14 09:17:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1695943213; cv=none; d=zohomail.com; s=zohoarc; b=h8TU5M4KX4zumdfdU0dxAfH8wSU4w2wmTc3fAwNLXtUJmw/0Wwklt7hShxUxeKyx62WLqSVfAQsGksyIu+IQS/gu6jnA+y44BtVb0KM3ioI8xJmCRL4AJzuRwAbajYE5EksedC+RBqRpfX0MVCFtPYt5CisCZC36U55vcpTXT8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695943213; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yq32tJnjVPi0z2MoxNzoP3nmP/w0YsbUxnmfU/xjCrc=; b=dgRXBa0yXjI/3AovID9zXRgCWmywF838lfeouBRE2e14r/c/5HCC4pfrngGBkdNW9taozAS74apMB3w9L1TasGXvkqdWCpKZg1HdNmVFw954A3Jiw7unqCaj6kxmUrOmuGvBfSPk3UG6/u6KcccgiPPihHVSslepnnPwZnTiEAg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1695943213301753.0188329476965; Thu, 28 Sep 2023 16:20:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.610077.949335 (Exim 4.92) (envelope-from ) id 1qm0IP-0003NV-B3; Thu, 28 Sep 2023 23:19:49 +0000 Received: by outflank-mailman (output) from mailman id 610077.949335; Thu, 28 Sep 2023 23:19:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qm0IP-0003NM-7z; Thu, 28 Sep 2023 23:19:49 +0000 Received: by outflank-mailman (input) for mailman id 610077; Thu, 28 Sep 2023 23:19:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qm0IN-0003MQ-Ri for xen-devel@lists.xenproject.org; Thu, 28 Sep 2023 23:19:47 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 80a0531a-5e55-11ee-9b0d-b553b5be7939; Fri, 29 Sep 2023 01:19:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 9C44282853BD; Thu, 28 Sep 2023 18:19:41 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id W-RDBVAdorpd; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 677D382856BA; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 7oh06pz4SJAY; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) Received: from raptor-ewks-026.rptsys.com (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 116AD82856A3; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 80a0531a-5e55-11ee-9b0d-b553b5be7939 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 677D382856BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1695943178; bh=yq32tJnjVPi0z2MoxNzoP3nmP/w0YsbUxnmfU/xjCrc=; h=From:To:Date:Message-Id:MIME-Version; b=OcDVyObeeEUYxXGFJnYIeEtpA8HetstdTgrgltg70dOZdVrQGVDD56vsKgK4LuErM nM9/aN/NLpj5mdaML3wefZaqMbRmze1Y1U7TXAtvAmMmB/j4+VBB1n3TxWuXbCPWEm 9vnFMKWKajjKr9XJr6U8kO+VAN2QsALORwMoA+0U= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH 1/3] xen/ppc: Fix stack initialization in head.S Date: Thu, 28 Sep 2023 18:19:27 -0500 Message-Id: <4d733b1f17215616b7ab00f0e44d2f483436b1d6.1695942864.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1695943214634100001 Content-Type: text/plain; charset="utf-8" The code to set up the stack in head.S erroneously loads the bottom of the stack (the symbol cpu0_boot_stack) into r1 instead of the top of the stack (cpu0_boot_stack + STACK_SIZE). Fixes: 3a4e6f67bc68 ("xen/ppc: Set up a basic C environment") Signed-off-by: Shawn Anastasio Reviewed-by: Andrew Cooper --- xen/arch/ppc/ppc64/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/ppc/ppc64/head.S b/xen/arch/ppc/ppc64/head.S index e600ddb05f..6ce313aff8 100644 --- a/xen/arch/ppc/ppc64/head.S +++ b/xen/arch/ppc/ppc64/head.S @@ -46,7 +46,7 @@ ENTRY(start) .L_correct_address: =20 /* set up the initial stack */ - LOAD_REG_ADDR(%r1, cpu0_boot_stack) + LOAD_REG_ADDR(%r1, cpu0_boot_stack + STACK_SIZE) li %r11, 0 stdu %r11, -STACK_FRAME_OVERHEAD(%r1) =20 --=20 2.30.2 From nobody Tue May 14 09:17:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1695943213; cv=none; d=zohomail.com; s=zohoarc; b=bNoDITCGh0K536lJYKjdVtAbehJOuOtr/HRPV6yySs1f8nlK7wfJDdSFGK2/tHQA/wB7OcCop6ZSqa/DzL7HNvBcJ/wx08YygJERMSwPQwFRJi6ihdkOmbPuVkveGdhQPFZTPY30Np8XI/o1P38Zq6z7c5jrizZnam3bVKOhKDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695943213; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WMnR/C+eSXX7X3ub66zwiAaYNV2V3FLjeRwKCWkfcKI=; b=VNPhRqVWKsKX5FpTRo/eNSi14sqA7o8fbMFFuyei61KunSJUO0FInTpShbbaYN8U0J9na0cfpGTl4fPq8JryxgqJqL8Urfw2u1MParuGC4C7FDmcoBKHnJg9RwBgSufKcl+gnaTuyGqAFaoOz7oy3N9mrYauHsItJEm7e01HwkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1695943213289163.0965885978145; Thu, 28 Sep 2023 16:20:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.610075.949315 (Exim 4.92) (envelope-from ) id 1qm0IK-0002se-Tr; Thu, 28 Sep 2023 23:19:44 +0000 Received: by outflank-mailman (output) from mailman id 610075.949315; Thu, 28 Sep 2023 23:19:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qm0IK-0002sX-Pv; Thu, 28 Sep 2023 23:19:44 +0000 Received: by outflank-mailman (input) for mailman id 610075; Thu, 28 Sep 2023 23:19:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qm0IK-0002sR-DA for xen-devel@lists.xenproject.org; Thu, 28 Sep 2023 23:19:44 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 80e37062-5e55-11ee-878b-cb3800f73035; Fri, 29 Sep 2023 01:19:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id B139D82856BA; Thu, 28 Sep 2023 18:19:41 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id kpdzDgLxv7cd; Thu, 28 Sep 2023 18:19:39 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 0B06B82856A3; Thu, 28 Sep 2023 18:19:39 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aFswkOKDHXrZ; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) Received: from raptor-ewks-026.rptsys.com (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 6651D8284D90; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 80e37062-5e55-11ee-878b-cb3800f73035 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 0B06B82856A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1695943179; bh=WMnR/C+eSXX7X3ub66zwiAaYNV2V3FLjeRwKCWkfcKI=; h=From:To:Date:Message-Id:MIME-Version; b=dHYb9QEidfv4o3XuTsIdia8HCBvDOUo1Rm9h2eMv2nFnWi/LVzI7x/9BTm74awf3y ABxH4u/8ZHSiRiLEd72Q+qaGCa+ueJXuIKPMV7lm949p7iG6WCECGdQd+/dfyuEiue qGMb03rzWjV/71/Tftxl67vS0B32CGhc54urHpco= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH 2/3] xen/ppc: Add .text.exceptions section for exception vectors Date: Thu, 28 Sep 2023 18:19:28 -0500 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1695943214874100003 Content-Type: text/plain; charset="utf-8" On Power, the exception vectors must lie at a fixed address, depending on the state of the Alternate Interrupt Location (AIL) field of the Logical Partition Control Register (LPCR). Create a .text.exceptions section in the linker script at an address suitable for AIL=3D3 plus an accompanying assertion to pave the way for implementing exception support. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/config.h | 3 +++ xen/arch/ppc/xen.lds.S | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/xen/arch/ppc/include/asm/config.h b/xen/arch/ppc/include/asm/c= onfig.h index a11a09c570..e012b75beb 100644 --- a/xen/arch/ppc/include/asm/config.h +++ b/xen/arch/ppc/include/asm/config.h @@ -42,6 +42,9 @@ =20 #define XEN_VIRT_START _AC(0xc000000000000000, UL) =20 +/* Fixed address for start of the section containing exception vectors */ +#define EXCEPTION_VECTORS_START _AC(0xc000000000000100, UL) + #define VMAP_VIRT_START (XEN_VIRT_START + GB(1)) #define VMAP_VIRT_SIZE GB(1) =20 diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S index 9e46035155..9e888d7383 100644 --- a/xen/arch/ppc/xen.lds.S +++ b/xen/arch/ppc/xen.lds.S @@ -24,6 +24,10 @@ SECTIONS _stext =3D .; /* Text section */ *(.text.header) =20 + . =3D ALIGN(256); + _stext_exceptions =3D .; + *(.text.exceptions) + *(.text.cold) *(.text.unlikely .text.*_unlikely .text.unlikely.*) =20 @@ -184,3 +188,6 @@ ASSERT(IS_ALIGNED(__bss_end, POINTER_ALIGN), "__= bss_end is misaligned") =20 ASSERT(!SIZEOF(.got), ".got non-empty") ASSERT(!SIZEOF(.got.plt), ".got.plt non-empty") + +ASSERT(_stext_exceptions =3D=3D EXCEPTION_VECTORS_START, \ + ".text.exceptions not at expected location -- .text.header too big?= "); --=20 2.30.2 From nobody Tue May 14 09:17:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1695943217; cv=none; d=zohomail.com; s=zohoarc; b=KOYLuM2QSMebt1b/ONlaMQqtr5GNiAkGPj49+J3I6Vvw32jn+gGfNx7edR49sJi0OO/sNgJ6ebHGJR2AHymR7kDxpNrRkUcz96HSnhwQv1mM6GfFE6eVtA+lHfHnkhBjJ4nDxqnMoGynUssDSPavKXx1Zkk5yBo1B/Z5mfVOmlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695943217; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sdfjUy1B7pxMGdguio7N5pjwT+r7o+wuvEx5hP1/rzw=; b=hw08vipbaHGdSOYvDMnr88Etthw+VjWzJHqIaA92hTsgdnrRQg3r6OrWPC3bxJ1ncru9YkxByECSj8ocmLA8ULuyF8WOI1B2Os+MLNcGI4elZEjZAGp/0vfS/23r/BN4fCY2iQRThe61sDgH0gaXwfyFyR2Sq1b9b0W5b9UmPgI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1695943217490381.38141901012216; Thu, 28 Sep 2023 16:20:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.610078.949345 (Exim 4.92) (envelope-from ) id 1qm0IQ-0003dg-IO; Thu, 28 Sep 2023 23:19:50 +0000 Received: by outflank-mailman (output) from mailman id 610078.949345; Thu, 28 Sep 2023 23:19:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qm0IQ-0003dZ-Eo; Thu, 28 Sep 2023 23:19:50 +0000 Received: by outflank-mailman (input) for mailman id 610078; Thu, 28 Sep 2023 23:19:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qm0IO-0003MQ-H3 for xen-devel@lists.xenproject.org; Thu, 28 Sep 2023 23:19:48 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8159849b-5e55-11ee-9b0d-b553b5be7939; Fri, 29 Sep 2023 01:19:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id D566582856A3; Thu, 28 Sep 2023 18:19:42 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7ql7Jw5hxUIB; Thu, 28 Sep 2023 18:19:40 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id F37C782858AE; Thu, 28 Sep 2023 18:19:39 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bsWFJGSbE-tz; Thu, 28 Sep 2023 18:19:39 -0500 (CDT) Received: from raptor-ewks-026.rptsys.com (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id BF8438285A09; Thu, 28 Sep 2023 18:19:38 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8159849b-5e55-11ee-9b0d-b553b5be7939 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com F37C782858AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1695943180; bh=sdfjUy1B7pxMGdguio7N5pjwT+r7o+wuvEx5hP1/rzw=; h=From:To:Date:Message-Id:MIME-Version; b=CjRoOL8UEQiUg7rcw03yTicFDLazRCQijNWvqIh+rOXv4Z+IAp5EZCQVsD23R+zyA n2m1MW+uuPCUXamblAvIs6KF138wpQoksfW0oM0lZzDVjmLL8+NFtFLlyXxj0cHZKT t6ZJPhTCs5np7NeAS9zur9uLFhjExd2MzuHpQHMk= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH 3/3] xen/ppc: Implement a basic exception handler Date: Thu, 28 Sep 2023 18:19:29 -0500 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1695943219189100001 Content-Type: text/plain; charset="utf-8" Implement a basic exception handler that dumps the CPU state to the console, as well as the code required to set the correct exception vector table's base address in setup.c. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/processor.h | 31 +++++++ xen/arch/ppc/ppc64/Makefile | 2 + xen/arch/ppc/ppc64/asm-offsets.c | 1 + xen/arch/ppc/ppc64/exceptions-asm.S | 122 +++++++++++++++++++++++++++ xen/arch/ppc/ppc64/exceptions.c | 102 ++++++++++++++++++++++ xen/arch/ppc/setup.c | 11 +++ 6 files changed, 269 insertions(+) create mode 100644 xen/arch/ppc/ppc64/exceptions-asm.S create mode 100644 xen/arch/ppc/ppc64/exceptions.c diff --git a/xen/arch/ppc/include/asm/processor.h b/xen/arch/ppc/include/as= m/processor.h index d3dd943c20..a01b62b8a4 100644 --- a/xen/arch/ppc/include/asm/processor.h +++ b/xen/arch/ppc/include/asm/processor.h @@ -103,6 +103,37 @@ #define PVR_BE 0x0070 #define PVR_PA6T 0x0090 =20 +/* Exception Definitions */ +#define EXC_SYSTEM_RESET 0x0100 /* System Reset Interrupt */ +#define EXC_MACHINE_CHECK 0x0200 /* Machine Check Interrupt */ +#define EXC_DATA_STORAGE 0x0300 /* Data Storage Interrupt */ +#define EXC_DATA_SEGMENT 0x0380 /* Data Segment Interrupt */ +#define EXC_INSN_STORAGE 0x0400 /* Instruction Storage Interrupt */ +#define EXC_INSN_SEGMENT 0x0480 /* Instruction Segment Interrupt */ +#define EXC_EXTERNAL 0x0500 /* External Interrupt */ +#define EXC_ALIGNMENT 0x0600 /* Alignment Interrupt */ +#define EXC_PROGRAM 0x0700 /* Program Interrupt */ +#define EXC_FPU_UNAVAIL 0x0800 /* Floating-Point Unavailable Interrupt= */ +#define EXC_DECREMENTER 0x0900 /* Decrementer Interrupt */ +#define EXC_H_DECREMENTER 0x0980 /* Hypervisor Decrementer Interrupt */ +#define EXC_PRIV_DOORBELL 0x0A00 /* Directed Privileged Doorbell Interru= pt */ +#define EXC_SYSTEM_CALL 0x0C00 /* System Call Interrupt */ +#define EXC_TRACE 0x0D00 /* Trace Interrupt */ +#define EXC_H_DATA_STORAGE 0x0E00 /* Hypervisor Data Storage Interrupt */ +#define EXC_H_INSN_STORAGE 0x0E20 /* Hypervisor Instruction Storage Inter= rupt */ +#define EXC_H_EMUL_ASST 0x0E40 /* Hypervisor Emulation Assistance Inte= rrupt */ +#define EXC_H_MAINTENANCE 0x0E60 /* Hypervisor Maintenance Interrupt */ +#define EXC_H_DOORBELL 0x0E80 /* Directed Hypervisor Doorbell Interru= pt */ +#define EXC_H_VIRT 0x0EA0 /* Hypervisor Virtualization Interrupt = */ +#define EXC_PERF_MON 0x0F00 /* Performance Monitor Interrupt */ +#define EXC_VECTOR_UNAVAIL 0x0F20 /* Vector Unavailable Interrupt */ +#define EXC_VSX_UNAVAIL 0x0F40 /* VSX Unavailable Interrupt */ +#define EXC_FACIL_UNAVAIL 0x0F60 /* Facility Unavailable Interrupt */ +#define EXC_H_FACIL_UNAVAIL 0x0F80 /* Hypervisor Facility Unavailable Inte= rrupt */ + +/* Base address of interrupt vector table when LPCR[AIL]=3D3 */ +#define AIL_VECTOR_BASE _AC(0xc000000000004000, UL) + #ifndef __ASSEMBLY__ =20 #include diff --git a/xen/arch/ppc/ppc64/Makefile b/xen/arch/ppc/ppc64/Makefile index 5b88355bb2..914bb21c40 100644 --- a/xen/arch/ppc/ppc64/Makefile +++ b/xen/arch/ppc/ppc64/Makefile @@ -1,2 +1,4 @@ +obj-y +=3D exceptions.o +obj-y +=3D exceptions-asm.o obj-y +=3D head.o obj-y +=3D opal-calls.o diff --git a/xen/arch/ppc/ppc64/asm-offsets.c b/xen/arch/ppc/ppc64/asm-offs= ets.c index c15c1bf136..634d7260e3 100644 --- a/xen/arch/ppc/ppc64/asm-offsets.c +++ b/xen/arch/ppc/ppc64/asm-offsets.c @@ -46,6 +46,7 @@ void __dummy__(void) OFFSET(UREGS_dsisr, struct cpu_user_regs, dsisr); OFFSET(UREGS_cr, struct cpu_user_regs, cr); OFFSET(UREGS_fpscr, struct cpu_user_regs, fpscr); + OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector); DEFINE(UREGS_sizeof, sizeof(struct cpu_user_regs)); =20 OFFSET(OPAL_base, struct opal, base); diff --git a/xen/arch/ppc/ppc64/exceptions-asm.S b/xen/arch/ppc/ppc64/excep= tions-asm.S new file mode 100644 index 0000000000..877df97c9b --- /dev/null +++ b/xen/arch/ppc/ppc64/exceptions-asm.S @@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include + + /* Helper to dump CPU state to struct cpu_user_regs pointed to by r1. = */ +ENTRY(exception_common) + /* Save GPRs 1-31 */ + SAVE_GPRS(1, 31, %r1) + + /* Save LR, CTR, CR */ + mflr %r0 + std %r0, UREGS_lr(%r1) + mfctr %r0 + std %r0, UREGS_ctr(%r1) + mfcr %r0 + stw %r0, UREGS_cr(%r1) /* 32-bit */ + + /* Save Exception Registers */ + mfsrr0 %r0 + std %r0, UREGS_pc(%r1) + mfsrr1 %r0 + std %r0, UREGS_msr(%r1) + mfdsisr %r0 + stw %r0, UREGS_dsisr(%r1) /* 32-bit */ + mfdar %r0 + std %r0, UREGS_dar(%r1) + li %r0, -1 /* OS's SRR0/SRR1 have been clobbered */ + std %r0, UREGS_srr0(%r1) + std %r0, UREGS_srr1(%r1) + + /* Setup TOC and a stack frame then call C exception handler */ + mr %r3, %r1 + bcl 20, 31, 1f +1: mflr %r12 + addis %r2, %r12, .TOC.-1b@ha + addi %r2, %r2, .TOC.-1b@l + + li %r0, 0 + stdu %r0, -STACK_FRAME_OVERHEAD(%r1) + bl exception_handler + + .size exception_common, . - exception_common + .type exception_common, %function + + /* Same as exception_common, but for exceptions that set HSRR{0,1} */ +ENTRY(h_exception_common) + /* Save GPRs 1-31 */ + SAVE_GPRS(1, 31, %r1) + + /* Save LR, CTR, CR */ + mflr %r0 + std %r0, UREGS_lr(%r1) + mfctr %r0 + std %r0, UREGS_ctr(%r1) + mfcr %r0 + stw %r0, UREGS_cr(%r1) /* 32-bit */ + + /* Save Exception Registers */ + mfhsrr0 %r0 + std %r0, UREGS_pc(%r1) + mfhsrr1 %r0 + std %r0, UREGS_msr(%r1) + mfsrr0 %r0 + std %r0, UREGS_srr0(%r1) + mfsrr1 %r0 + std %r0, UREGS_srr1(%r1) + mfdsisr %r0 + stw %r0, UREGS_dsisr(%r1) /* 32-bit */ + mfdar %r0 + std %r0, UREGS_dar(%r1) + + /* Setup TOC and a stack frame then call C exception handler */ + mr %r3, %r1 + bcl 20, 31, 1f +1: mflr %r12 + addis %r2, %r12, .TOC.-1b@ha + addi %r2, %r2, .TOC.-1b@l + + li %r0, 0 + stdu %r0, -STACK_FRAME_OVERHEAD(%r1) + bl exception_handler + + .size h_exception_common, . - h_exception_common + .type h_exception_common, %function + +/* + * Declare an ISR for the provided exception that jumps to `continue` + */ +#define DEFINE_ISR(name, exc, continue) = \ + . =3D (AIL_VECTOR_BASE - EXCEPTION_VECTORS_START) + (exc); = \ + ENTRY(name) = \ + /* TODO: switch stack */ = \ + /* Reserve space for struct cpu_user_regs */ = \ + subi %r1, %r1, UREGS_sizeof; = \ + /* Save r0 immediately so we can use it as scratch space */ = \ + SAVE_GPR(0, %r1); = \ + /* Save exception vector number */ = \ + li %r0, (exc); = \ + std %r0, UREGS_entry_vector(%r1); = \ + /* Branch to common code */ = \ + b (continue); = \ + .size name, . - name; = \ + .type name, %function; + + .section .text.exceptions, "ax", %progbits + +DEFINE_ISR(exc_sysreset, EXC_SYSTEM_RESET, exception_common) +DEFINE_ISR(exc_mcheck, EXC_MACHINE_CHECK, exception_common) +DEFINE_ISR(exc_dstore, EXC_DATA_STORAGE, exception_common) +DEFINE_ISR(exc_dsegment, EXC_DATA_SEGMENT, exception_common) +DEFINE_ISR(exc_istore, EXC_INSN_STORAGE, exception_common) +DEFINE_ISR(exc_isegment, EXC_INSN_SEGMENT, exception_common) +DEFINE_ISR(exc_extern, EXC_EXTERNAL, exception_common) +DEFINE_ISR(exc_align, EXC_ALIGNMENT, exception_common) +DEFINE_ISR(exc_program, EXC_PROGRAM, exception_common) +DEFINE_ISR(exc_fpu, EXC_FPU_UNAVAIL, exception_common) +DEFINE_ISR(exc_dec, EXC_DECREMENTER, exception_common) +DEFINE_ISR(exc_h_dec, EXC_H_DECREMENTER, h_exception_common) +/* EXC_PRIV_DOORBELL ... EXC_TRACE */ +DEFINE_ISR(exc_h_dstore, EXC_H_DATA_STORAGE, h_exception_common) +DEFINE_ISR(exc_h_istore, EXC_H_INSN_STORAGE, h_exception_common) diff --git a/xen/arch/ppc/ppc64/exceptions.c b/xen/arch/ppc/ppc64/exception= s.c new file mode 100644 index 0000000000..ad5ab545f0 --- /dev/null +++ b/xen/arch/ppc/ppc64/exceptions.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include + +#include + +static const char *exception_name_from_vec(uint32_t vec) +{ + switch ( vec ) + { + case EXC_SYSTEM_RESET: + return "System Reset Interrupt"; + case EXC_MACHINE_CHECK: + return "Machine Check Interrupt"; + case EXC_DATA_STORAGE: + return "Data Storage Interrupt"; + case EXC_DATA_SEGMENT: + return "Data Segment Interrupt"; + case EXC_INSN_STORAGE: + return "Instruction Storage Interrupt"; + case EXC_INSN_SEGMENT: + return "Instruction Segment Interrupt"; + case EXC_EXTERNAL: + return "External Interrupt"; + case EXC_ALIGNMENT: + return "Alignment Interrupt"; + case EXC_PROGRAM: + return "Program Interrupt"; + case EXC_FPU_UNAVAIL: + return "Floating-Point Unavailable Interrupt"; + case EXC_DECREMENTER: + return "Decrementer Interrupt"; + case EXC_H_DECREMENTER: + return "Hypervisor Decrementer Interrupt"; + case EXC_PRIV_DOORBELL: + return "Directed Privileged Doorbell Interrupt"; + case EXC_SYSTEM_CALL: + return "System Call Interrupt"; + case EXC_TRACE: + return "Trace Interrupt"; + case EXC_H_DATA_STORAGE: + return "Hypervisor Data Storage Interrupt"; + case EXC_H_INSN_STORAGE: + return "Hypervisor Instruction Storage Interrupt"; + case EXC_H_EMUL_ASST: + return "Hypervisor Emulation Assistance Interrupt"; + case EXC_H_MAINTENANCE: + return "Hypervisor Maintenance Interrupt"; + case EXC_H_DOORBELL: + return "Directed Hypervisor Doorbell Interrupt"; + case EXC_H_VIRT: + return "Hypervisor Virtualization Interrupt"; + case EXC_PERF_MON: + return "Performance Monitor Interrupt"; + case EXC_VECTOR_UNAVAIL: + return "Vector Unavailable Interrupt"; + case EXC_VSX_UNAVAIL: + return "VSX Unavailable Interrupt"; + case EXC_FACIL_UNAVAIL: + return "Facility Unavailable Interrupt"; + case EXC_H_FACIL_UNAVAIL: + return "Hypervisor Facility Unavailable Interrupt"; + default: + return "(unknown)"; + } +} + +void exception_handler(struct cpu_user_regs *regs) +{ + /* TODO: this is currently only useful for debugging */ + + printk("UNRECOVERABLE EXCEPTION: %s (0x%04x)\n\n" + "GPR 0-3 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 4-7 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 8-11 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 12-15 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 16-19 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 20-23 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 24-27 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n" + "GPR 28-31 : 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n\n", + exception_name_from_vec(regs->entry_vector), regs->entry_vector, + regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3], + regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7], + regs->gprs[8], regs->gprs[9], regs->gprs[10], regs->gprs[11], + regs->gprs[12], regs->gprs[13], regs->gprs[14], regs->gprs[15], + regs->gprs[16], regs->gprs[17], regs->gprs[18], regs->gprs[19], + regs->gprs[20], regs->gprs[21], regs->gprs[22], regs->gprs[23], + regs->gprs[24], regs->gprs[25], regs->gprs[26], regs->gprs[27], + regs->gprs[28], regs->gprs[29], regs->gprs[30], regs->gprs[31]); + printk("LR : 0x%016lx\n" + "CTR : 0x%016lx\n" + "CR : 0x%08x\n" + "PC : 0x%016lx\n" + "MSR : 0x%016lx\n" + "SRR0 : 0x%016lx\n" + "SRR1 : 0x%016lx\n" + "DAR : 0x%016lx\n" + "DSISR : 0x%08x\n", + regs->lr, regs->ctr, regs->cr, regs->pc, regs->msr, regs->srr0, + regs->srr1, regs->dar, regs->dsisr); + + die(); +} diff --git a/xen/arch/ppc/setup.c b/xen/arch/ppc/setup.c index 959c1454a0..101bdd8bb6 100644 --- a/xen/arch/ppc/setup.c +++ b/xen/arch/ppc/setup.c @@ -11,6 +11,15 @@ /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); =20 +void setup_exceptions(void) +{ + unsigned long lpcr; + + /* Set appropriate interrupt location in LPCR */ + lpcr =3D mfspr(SPRN_LPCR); + mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3); +} + void __init noreturn start_xen(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7) @@ -26,6 +35,8 @@ void __init noreturn start_xen(unsigned long r3, unsigned= long r4, boot_opal_init((void *)r3); } =20 + setup_exceptions(); + setup_initial_pagetables(); =20 early_printk("Hello, ppc64le!\n"); --=20 2.30.2