From patchwork Fri Aug 12 19:24:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7144FC25B0E for ; Fri, 12 Aug 2022 19:25:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385855.621639 (Exim 4.92) (envelope-from ) id 1oMaHP-0000Ve-1A; Fri, 12 Aug 2022 19:25:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385855.621639; Fri, 12 Aug 2022 19:25:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHO-0000VX-T8; Fri, 12 Aug 2022 19:25:10 +0000 Received: by outflank-mailman (input) for mailman id 385855; Fri, 12 Aug 2022 19:25:09 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHN-0000FX-4o for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:09 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHM-0000xY-SH; Fri, 12 Aug 2022 19:25:08 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHM-0006n6-Js; Fri, 12 Aug 2022 19:25:08 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1G2Qt2AMX5j11jO0S4LFhw33Cq6gRJqjfValRIvJxXM=; b=wG7b+kJxPPFG3besl9gWU5of8e C7nM6s3pbhEZDBdgS9KDNWWChZVzaYR74kPR/yg6YpR8XR+7tSIszLd7l5cG+YPywhg3qLBj4HuC3 GF+2LuvmVa29mkcrbf53zQ5V/vVzdsqoR3Cee/qRnf6TJX4z0oPfDuQBugPX+Gd1hzuM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 1/7] xen/arm64: head: Don't set x22 and update the documentation Date: Fri, 12 Aug 2022 20:24:40 +0100 Message-Id: <20220812192448.43016-2-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Since commit 7e14a47e7c73 ("xen/arm64: head Rework and document launch()"), the boot code is setting x22 but not read it. So remove the two instructions setting x22 and update the documentation to show x22 has no specific purpose. Signed-off-by: Julien Grall Reviewed-by: Wei Chen Reviewed-by: Bertrand Marquis --- xen/arch/arm/arm64/head.S | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 1babcc65d7c9..26cc7705f556 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -71,7 +71,7 @@ * x19 - paddr(start) * x20 - phys offset * x21 - DTB address (boot cpu only) - * x22 - is_secondary_cpu + * x22 - * x23 - UART address * x24 - * x25 - @@ -305,8 +305,6 @@ real_start_efi: #endif PRINT("- Boot CPU booting -\r\n") - mov x22, #0 /* x22 := is_secondary_cpu */ - bl check_cpu_mode bl cpu_init bl create_page_tables @@ -345,8 +343,6 @@ GLOBAL(init_secondary) adr x19, start /* x19 := paddr (start) */ sub x20, x19, x0 /* x20 := phys-offset */ - mov x22, #1 /* x22 := is_secondary_cpu */ - mrs x0, mpidr_el1 ldr x13, =(~MPIDR_HWID_MASK) bic x24, x0, x13 /* Mask out flags to get CPU ID */ From patchwork Fri Aug 12 19:24:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F264CC28B2B for ; Fri, 12 Aug 2022 19:25:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385856.621647 (Exim 4.92) (envelope-from ) id 1oMaHP-0000d8-JI; Fri, 12 Aug 2022 19:25:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385856.621647; Fri, 12 Aug 2022 19:25:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHP-0000bb-CI; Fri, 12 Aug 2022 19:25:11 +0000 Received: by outflank-mailman (input) for mailman id 385856; Fri, 12 Aug 2022 19:25:10 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHO-0000OU-3A for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:10 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHN-0000xo-TP; Fri, 12 Aug 2022 19:25:09 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHN-0006n6-LI; Fri, 12 Aug 2022 19:25:09 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ngshIEE2EN6MEfw9zmbHPOq0MvbgTTFSHuQTBxj5Rkw=; b=6AOrZflQqxWt6ZUuxW+F80X5TW UkChC67IgilFd/Mv8haKA1DcebMlYmv7kYezggohNyTbySnsmPaTpFm+bsWk+RkYu01XIg9PCzByT e5e6SvFQz0NFelgVgSfpcKU/8vim9tSGvDSFS6WqnAl2WAJ7mZSvqTgxE+5FR5qXKcB4=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 2/7] xen/arm64: head: Introduce get_table_slot() and use it Date: Fri, 12 Aug 2022 20:24:41 +0100 Message-Id: <20220812192448.43016-3-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall There are a few places in the code that need to find the slot at a given page-table level. So create a new macro get_table_slot() for that. This will reduce the effort to figure out whether the code is doing the right thing. Take the opportunity to use 'ubfx'. The only benefits is reducing the number of instructions from 2 to 1. The new macro is used everywhere we need to compute the slot. This requires to tweak the parameter of create_table_entry() to pass a level rather than shift. Note, for slot 0 the code is currently skipping the masking part. While this is fine, it is safer to mask it as technically slot 0 only covers bit 48 - 39 bit (assuming 4KB page granularity). Take the opportunity to correct the comment when finding the second slot for the identity mapping (we are computing the second slot rather than first). Signed-off-by: Julien Grall ---- This patch also has the benefits to reduce the number of use of {ZEROETH, FIRST, SECOND, THIRD}_SHIFT. The next patch for arm32 will reduce further. Reviewed-by: Wei Chen Reviewed-by: Bertrand Marquis --- xen/arch/arm/arm64/head.S | 55 +++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 26cc7705f556..ad014716db6f 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -493,13 +493,24 @@ cpu_init: ret ENDPROC(cpu_init) +/* + * Macro to find the slot number at a given page-table level + * + * slot: slot computed + * virt: virtual address + * lvl: page-table level + */ +.macro get_table_slot, slot, virt, lvl + ubfx \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl), #XEN_PT_LPAE_SHIFT +.endm + /* * Macro to create a page table entry in \ptbl to \tbl * * ptbl: table symbol where the entry will be created * tbl: table symbol to point to * virt: virtual address - * shift: #imm page table shift + * lvl: page-table level * tmp1: scratch register * tmp2: scratch register * tmp3: scratch register @@ -511,9 +522,8 @@ ENDPROC(cpu_init) * * Note that all parameters using registers should be distinct. */ -.macro create_table_entry, ptbl, tbl, virt, shift, tmp1, tmp2, tmp3 - lsr \tmp1, \virt, #\shift - and \tmp1, \tmp1, #XEN_PT_LPAE_ENTRY_MASK/* \tmp1 := slot in \tlb */ +.macro create_table_entry, ptbl, tbl, virt, lvl, tmp1, tmp2, tmp3 + get_table_slot \tmp1, \virt, \lvl /* \tmp1 := slot in \tlb */ load_paddr \tmp2, \tbl mov \tmp3, #PT_PT /* \tmp3 := right for linear PT */ @@ -544,8 +554,7 @@ ENDPROC(cpu_init) .macro create_mapping_entry, ptbl, virt, phys, tmp1, tmp2, tmp3, type=PT_MEM_L3 and \tmp3, \phys, #THIRD_MASK /* \tmp3 := PAGE_ALIGNED(phys) */ - lsr \tmp1, \virt, #THIRD_SHIFT - and \tmp1, \tmp1, #XEN_PT_LPAE_ENTRY_MASK/* \tmp1 := slot in \tlb */ + get_table_slot \tmp1, \virt, 3 /* \tmp1 := slot in \tlb */ mov \tmp2, #\type /* \tmp2 := right for section PT */ orr \tmp2, \tmp2, \tmp3 /* + PAGE_ALIGNED(phys) */ @@ -573,9 +582,9 @@ ENDPROC(cpu_init) create_page_tables: /* Prepare the page-tables for mapping Xen */ ldr x0, =XEN_VIRT_START - create_table_entry boot_pgtable, boot_first, x0, ZEROETH_SHIFT, x1, x2, x3 - create_table_entry boot_first, boot_second, x0, FIRST_SHIFT, x1, x2, x3 - create_table_entry boot_second, boot_third, x0, SECOND_SHIFT, x1, x2, x3 + create_table_entry boot_pgtable, boot_first, x0, 0, x1, x2, x3 + create_table_entry boot_first, boot_second, x0, 1, x1, x2, x3 + create_table_entry boot_second, boot_third, x0, 2, x1, x2, x3 /* Map Xen */ adr_l x4, boot_third @@ -612,10 +621,10 @@ create_page_tables: * XEN_ZEROETH_SLOT, then the 1:1 mapping will use its own set of * page-tables from the first level. */ - lsr x0, x19, #ZEROETH_SHIFT /* x0 := zeroeth slot */ + get_table_slot x0, x19, 0 /* x0 := zeroeth slot */ cmp x0, #XEN_ZEROETH_SLOT beq 1f - create_table_entry boot_pgtable, boot_first_id, x19, ZEROETH_SHIFT, x0, x1, x2 + create_table_entry boot_pgtable, boot_first_id, x19, 0, x0, x1, x2 b link_from_first_id 1: @@ -624,11 +633,10 @@ create_page_tables: * then the 1:1 mapping will use its own set of page-tables from * the second level. */ - lsr x0, x19, #FIRST_SHIFT - and x0, x0, #XEN_PT_LPAE_ENTRY_MASK /* x0 := first slot */ + get_table_slot x0, x19, 1 /* x0 := first slot */ cmp x0, #XEN_FIRST_SLOT beq 1f - create_table_entry boot_first, boot_second_id, x19, FIRST_SHIFT, x0, x1, x2 + create_table_entry boot_first, boot_second_id, x19, 1, x0, x1, x2 b link_from_second_id 1: @@ -638,17 +646,16 @@ create_page_tables: * third level. For slot XEN_SECOND_SLOT, Xen is not yet able to handle * it. */ - lsr x0, x19, #SECOND_SHIFT - and x0, x0, #XEN_PT_LPAE_ENTRY_MASK /* x0 := first slot */ + get_table_slot x0, x19, 2 /* x0 := second slot */ cmp x0, #XEN_SECOND_SLOT beq virtphys_clash - create_table_entry boot_second, boot_third_id, x19, SECOND_SHIFT, x0, x1, x2 + create_table_entry boot_second, boot_third_id, x19, 2, x0, x1, x2 b link_from_third_id link_from_first_id: - create_table_entry boot_first_id, boot_second_id, x19, FIRST_SHIFT, x0, x1, x2 + create_table_entry boot_first_id, boot_second_id, x19, 1, x0, x1, x2 link_from_second_id: - create_table_entry boot_second_id, boot_third_id, x19, SECOND_SHIFT, x0, x1, x2 + create_table_entry boot_second_id, boot_third_id, x19, 2, x0, x1, x2 link_from_third_id: create_mapping_entry boot_third_id, x19, x19, x0, x1, x2 ret @@ -705,7 +712,7 @@ remove_identity_mapping: * Find the zeroeth slot used. Remove the entry from zeroeth * table if the slot is not XEN_ZEROETH_SLOT. */ - lsr x1, x19, #ZEROETH_SHIFT /* x1 := zeroeth slot */ + get_table_slot x1, x19, 0 /* x1 := zeroeth slot */ cmp x1, #XEN_ZEROETH_SLOT beq 1f /* It is not in slot XEN_ZEROETH_SLOT, remove the entry. */ @@ -718,8 +725,7 @@ remove_identity_mapping: * Find the first slot used. Remove the entry for the first * table if the slot is not XEN_FIRST_SLOT. */ - lsr x1, x19, #FIRST_SHIFT - and x1, x1, #XEN_PT_LPAE_ENTRY_MASK /* x1 := first slot */ + get_table_slot x1, x19, 1 /* x1 := first slot */ cmp x1, #XEN_FIRST_SLOT beq 1f /* It is not in slot XEN_FIRST_SLOT, remove the entry. */ @@ -732,8 +738,7 @@ remove_identity_mapping: * Find the second slot used. Remove the entry for the first * table if the slot is not XEN_SECOND_SLOT. */ - lsr x1, x19, #SECOND_SHIFT - and x1, x1, #XEN_PT_LPAE_ENTRY_MASK /* x1 := first slot */ + get_table_slot x1, x19, 2 /* x1 := second slot */ cmp x1, #XEN_SECOND_SLOT beq identity_mapping_removed /* It is not in slot 1, remove the entry */ @@ -771,7 +776,7 @@ setup_fixmap: #endif /* Map fixmap into boot_second */ ldr x0, =FIXMAP_ADDR(0) - create_table_entry boot_second, xen_fixmap, x0, SECOND_SHIFT, x1, x2, x3 + create_table_entry boot_second, xen_fixmap, x0, 2, x1, x2, x3 /* Ensure any page table updates made above have occurred. */ dsb nshst From patchwork Fri Aug 12 19:24:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 003D7C2BB41 for ; Fri, 12 Aug 2022 19:25:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385857.621661 (Exim 4.92) (envelope-from ) id 1oMaHQ-00011V-Ow; Fri, 12 Aug 2022 19:25:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385857.621661; Fri, 12 Aug 2022 19:25:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHQ-00010t-KG; Fri, 12 Aug 2022 19:25:12 +0000 Received: by outflank-mailman (input) for mailman id 385857; Fri, 12 Aug 2022 19:25:11 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHP-0000YD-6H for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:11 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHO-0000y0-UO; Fri, 12 Aug 2022 19:25:10 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHO-0006n6-Mf; Fri, 12 Aug 2022 19:25:10 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=MmRrbC3kvaMa64yr7ie9nAhuc1w7gAgxG0UgP5uX0L8=; b=Ax34ql9MUHf8TDUrgS8BWDGqTs g4yKR+4WvfivmMOR11aWb0vt+SAxtgpbEwF6pNTU2PBsYflRFTyFGu8IyDpvorJzau1be9ndyADQQ c0EYoKQC5g7ekNGxJMPzwjUvFPG6vbUdQpCdse9Yi8i4CniZxDggKvIqOw3V4yZtRyu4=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 3/7] xen/arm32: head: Introduce get_table_slot() and use it Date: Fri, 12 Aug 2022 20:24:42 +0100 Message-Id: <20220812192448.43016-4-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall There are a few places in the code that need to find the slot at a given page-table level. So create a new macro get_table_slot() for that. This will reduce the effort to figure out whether the code is doing the right thing. The new macro is using 'ubfx' (or 'lsr' for the first level) rather than the existing sequence (mov_w, lsr, and) because it doesn't require a scratch register and reduce the number of instructions (4 -> 1). Signed-off-by: Julien Grall Reviewed-by: Wei Chen Reviewed-by: Bertrand Marquis Tested-by: Bertrand Marquis --- xen/arch/arm/arm32/head.S | 56 ++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 46d93bebbabe..50f6fa4eb38d 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -358,13 +358,31 @@ cpu_init_done: mov pc, r5 /* Return address is in r5 */ ENDPROC(cpu_init) +/* + * Macro to find the slot number at a given page-table level + * + * slot: slot computed + * virt: virtual address + * lvl: page-table level + * + * Note that ubxf is unpredictable when the end bit is above 32-bit. So we + * can't use it for first level offset. + */ +.macro get_table_slot, slot, virt, lvl + .if \lvl == 1 + lsr \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl) + .else + ubfx \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl), #XEN_PT_LPAE_SHIFT + .endif +.endm + /* * Macro to create a page table entry in \ptbl to \tbl * * ptbl: table symbol where the entry will be created * tbl: table symbol to point to * virt: virtual address - * shift: #imm page table shift + * lvl: page-table level * mmu: Is the MMU turned on/off. If not specified it will be off * * Preserves \virt @@ -374,11 +392,9 @@ ENDPROC(cpu_init) * * Note that \virt should be in a register other than r1 - r4 */ -.macro create_table_entry, ptbl, tbl, virt, shift, mmu=0 - lsr r1, \virt, #\shift - mov_w r2, XEN_PT_LPAE_ENTRY_MASK - and r1, r1, r2 /* r1 := slot in \tlb */ - lsl r1, r1, #3 /* r1 := slot offset in \tlb */ +.macro create_table_entry, ptbl, tbl, virt, lvl, mmu=0 + get_table_slot r1, \virt, \lvl /* r1 := slot in \tlb */ + lsl r1, r1, #3 /* r1 := slot offset in \tlb */ load_paddr r4, \tbl @@ -448,8 +464,8 @@ ENDPROC(cpu_init) create_page_tables: /* Prepare the page-tables for mapping Xen */ ldr r0, =XEN_VIRT_START - create_table_entry boot_pgtable, boot_second, r0, FIRST_SHIFT - create_table_entry boot_second, boot_third, r0, SECOND_SHIFT + create_table_entry boot_pgtable, boot_second, r0, 1 + create_table_entry boot_second, boot_third, r0, 2 /* Setup boot_third: */ adr_l r4, boot_third, mmu=0 @@ -486,12 +502,10 @@ create_page_tables: * then the 1:1 mapping will use its own set of page-tables from * the second level. */ - lsr r1, r9, #FIRST_SHIFT - mov_w r0, XEN_PT_LPAE_ENTRY_MASK - and r1, r1, r0 /* r1 := first slot */ + get_table_slot r1, r9, 1 /* r1 := first slot */ cmp r1, #XEN_FIRST_SLOT beq 1f - create_table_entry boot_pgtable, boot_second_id, r9, FIRST_SHIFT + create_table_entry boot_pgtable, boot_second_id, r9, 1 b link_from_second_id 1: @@ -501,16 +515,14 @@ create_page_tables: * third level. For slot XEN_SECOND_SLOT, Xen is not yet able to handle * it. */ - lsr r1, r9, #SECOND_SHIFT - mov_w r0, XEN_PT_LPAE_ENTRY_MASK - and r1, r1, r0 /* r1 := second slot */ + get_table_slot r1, r9, 2 /* r1 := second slot */ cmp r1, #XEN_SECOND_SLOT beq virtphys_clash - create_table_entry boot_second, boot_third_id, r9, SECOND_SHIFT + create_table_entry boot_second, boot_third_id, r9, 2 b link_from_third_id link_from_second_id: - create_table_entry boot_second_id, boot_third_id, r9, SECOND_SHIFT + create_table_entry boot_second_id, boot_third_id, r9, 2 link_from_third_id: create_mapping_entry boot_third_id, r9, r9 mov pc, lr @@ -571,9 +583,7 @@ remove_identity_mapping: * Find the first slot used. Remove the entry for the first * table if the slot is not XEN_FIRST_SLOT. */ - lsr r1, r9, #FIRST_SHIFT - mov_w r0, XEN_PT_LPAE_ENTRY_MASK - and r1, r1, r0 /* r1 := first slot */ + get_table_slot r1, r9, 1 /* r1 := first slot */ cmp r1, #XEN_FIRST_SLOT beq 1f /* It is not in slot 0, remove the entry */ @@ -587,9 +597,7 @@ remove_identity_mapping: * Find the second slot used. Remove the entry for the first * table if the slot is not XEN_SECOND_SLOT. */ - lsr r1, r9, #SECOND_SHIFT - mov_w r0, XEN_PT_LPAE_ENTRY_MASK - and r1, r1, r0 /* r1 := second slot */ + get_table_slot r1, r9, 2 /* r1 := second slot */ cmp r1, #XEN_SECOND_SLOT beq identity_mapping_removed /* It is not in slot 1, remove the entry */ @@ -628,7 +636,7 @@ setup_fixmap: #endif /* Map fixmap into boot_second */ mov_w r0, FIXMAP_ADDR(0) - create_table_entry boot_second, xen_fixmap, r0, SECOND_SHIFT, mmu=1 + create_table_entry boot_second, xen_fixmap, r0, 2, mmu=1 /* Ensure any page table updates made above have occurred. */ dsb nshst From patchwork Fri Aug 12 19:24:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DD7CC25B0F for ; Fri, 12 Aug 2022 19:25:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385858.621672 (Exim 4.92) (envelope-from ) id 1oMaHS-0001KW-69; Fri, 12 Aug 2022 19:25:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385858.621672; Fri, 12 Aug 2022 19:25:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHS-0001Jd-1j; Fri, 12 Aug 2022 19:25:14 +0000 Received: by outflank-mailman (input) for mailman id 385858; Fri, 12 Aug 2022 19:25:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHQ-0000wg-9V for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHP-0000yE-W3; Fri, 12 Aug 2022 19:25:11 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHP-0006n6-O5; Fri, 12 Aug 2022 19:25:11 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=UfWb+n83nlA+FfpERZvzgicr1KFfkvvT5C3RMOVERFw=; b=W2b0baSx43V013hbPf7SzcRvE0 v/ztQ6YwuCVWGKXQGcZxazGfi2Flfd+KVf1T8WS98QpgSNX+g6zRFe7dzqvLEMEwgAHE6WNpOb3Xo CEo/Uth0uA0+CJANi7xO3p5FxPZsW+wp2jGvk7cy2ZyfxGgeeUjKdg8HVpxN3qZ15vHM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 4/7] xen/arm32: heap: Rework adr_l so it doesn't rely on where Xen is loaded Date: Fri, 12 Aug 2022 20:24:43 +0100 Message-Id: <20220812192448.43016-5-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall At the moment, the macro addr_l needs to know whether the caller is running with the MMU on. This is fine today because there are only two possible cases: 1) MMU off 2) MMU on and linked to the virtual address This is still cumbersome to use for the developer as they need to know if the MMU is on. Thankfully, Linux developpers came up with a great way to allow adr_l to work within the range +/- 4GB of PC by emitting a PC-relative reference [1]. Re-use the same approach on Arm and drop the parameter 'mmu'. [1] 0b1674638a5c ("ARM: assembler: introduce adr_l, ldr_l and str_l macros") Signed-off-by: Julien Grall ---- I haven't added an Origin tag because this is quite different from the Linux commit. I am happy to add one if this is desired.. Reviewed-by: Wei Chen Reviewed-by: Bertrand Marquis --- xen/arch/arm/arm32/head.S | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 50f6fa4eb38d..27d02ac8d68f 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -49,20 +49,16 @@ .endm /* - * There are no easy way to have a PC relative address within the range - * +/- 4GB of the PC. + * Pseudo-op for PC relative adr , where is + * within the range +/- 4GB of the PC. * - * This macro workaround it by asking the user to tell whether the MMU - * has been turned on or not. - * - * When the MMU is turned off, we need to apply the physical offset - * (r10) in order to find the associated physical address. + * @dst: destination register + * @sym: name of the symbol */ -.macro adr_l, dst, sym, mmu - ldr \dst, =\sym - .if \mmu == 0 - add \dst, \dst, r10 - .endif +.macro adr_l, dst, sym + mov_w \dst, \sym - .Lpc\@ + .set .Lpc\@, .+ 8 /* PC bias */ + add \dst, \dst, pc .endm .macro load_paddr rb, sym @@ -383,7 +379,6 @@ ENDPROC(cpu_init) * tbl: table symbol to point to * virt: virtual address * lvl: page-table level - * mmu: Is the MMU turned on/off. If not specified it will be off * * Preserves \virt * Clobbers r1 - r4 @@ -392,7 +387,7 @@ ENDPROC(cpu_init) * * Note that \virt should be in a register other than r1 - r4 */ -.macro create_table_entry, ptbl, tbl, virt, lvl, mmu=0 +.macro create_table_entry, ptbl, tbl, virt, lvl get_table_slot r1, \virt, \lvl /* r1 := slot in \tlb */ lsl r1, r1, #3 /* r1 := slot offset in \tlb */ @@ -402,7 +397,7 @@ ENDPROC(cpu_init) orr r2, r2, r4 /* + \tlb paddr */ mov r3, #0 - adr_l r4, \ptbl, \mmu + adr_l r4, \ptbl strd r2, r3, [r4, r1] .endm @@ -415,17 +410,14 @@ ENDPROC(cpu_init) * virt: virtual address * phys: physical address * type: mapping type. If not specified it will be normal memory (PT_MEM_L3) - * mmu: Is the MMU turned on/off. If not specified it will be off * * Preserves \virt, \phys * Clobbers r1 - r4 * - * * Also use r10 for the phys offset. - * * Note that \virt and \paddr should be in other registers than r1 - r4 * and be distinct. */ -.macro create_mapping_entry, ptbl, virt, phys, type=PT_MEM_L3, mmu=0 +.macro create_mapping_entry, ptbl, virt, phys, type=PT_MEM_L3 mov_w r2, XEN_PT_LPAE_ENTRY_MASK lsr r1, \virt, #THIRD_SHIFT and r1, r1, r2 /* r1 := slot in \tlb */ @@ -438,7 +430,7 @@ ENDPROC(cpu_init) orr r2, r2, r4 /* + PAGE_ALIGNED(phys) */ mov r3, #0 - adr_l r4, \ptbl, \mmu + adr_l r4, \ptbl strd r2, r3, [r4, r1] .endm @@ -468,7 +460,7 @@ create_page_tables: create_table_entry boot_second, boot_third, r0, 2 /* Setup boot_third: */ - adr_l r4, boot_third, mmu=0 + adr_l r4, boot_third lsr r2, r9, #THIRD_SHIFT /* Base address for 4K mapping */ lsl r2, r2, #THIRD_SHIFT @@ -632,11 +624,11 @@ setup_fixmap: #if defined(CONFIG_EARLY_PRINTK) /* Add UART to the fixmap table */ ldr r0, =EARLY_UART_VIRTUAL_ADDRESS - create_mapping_entry xen_fixmap, r0, r11, type=PT_DEV_L3, mmu=1 + create_mapping_entry xen_fixmap, r0, r11, type=PT_DEV_L3 #endif /* Map fixmap into boot_second */ mov_w r0, FIXMAP_ADDR(0) - create_table_entry boot_second, xen_fixmap, r0, 2, mmu=1 + create_table_entry boot_second, xen_fixmap, r0, 2 /* Ensure any page table updates made above have occurred. */ dsb nshst From patchwork Fri Aug 12 19:24:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5498C28B2C for ; Fri, 12 Aug 2022 19:25:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385860.621683 (Exim 4.92) (envelope-from ) id 1oMaHT-0001cI-KC; Fri, 12 Aug 2022 19:25:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385860.621683; Fri, 12 Aug 2022 19:25:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHT-0001bf-CH; Fri, 12 Aug 2022 19:25:15 +0000 Received: by outflank-mailman (input) for mailman id 385860; Fri, 12 Aug 2022 19:25:13 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHR-0001CF-BA for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:13 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHR-0000yS-13; Fri, 12 Aug 2022 19:25:13 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHQ-0006n6-PT; Fri, 12 Aug 2022 19:25:12 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=KSNSRhk/b7PF+Veoqw2eqLMcjCDzJVoJhlmghRfM920=; b=ZCkoDm+ZTirO4BNHjMNk5xuq33 f3rtyXAH3xWYCjq79zyYeHN2QV+2yLqY6vW97Eu3JLKvZnY8hFYAFlnUO84vIXG3hmy+zt+pYG84p JnLwH6tMPpXjgCHTrYAZ3AgMerdBr8qCs382VleKjRokRwzoeBp0Xn7ubJG9iGjpm3tg=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 5/7] xen/arm32: head: Move earlyprintk messages to .rodata.str Date: Fri, 12 Aug 2022 20:24:44 +0100 Message-Id: <20220812192448.43016-6-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall At the moment, the strings are in text right after each use because the instruction 'adr' has specific requirement on the location and the compiler will forbid cross section label. The macro 'adr_l' was recently reworked so the caller doesn't need to know whether the MMU is on. This makes it easier to use where instructions can be run in both context. This also means that the strings don't need to be part of .text anymore. So move them to .rodata.str. Signed-off-by: Julien Grall Reviewed-by: Jiamei Xie Reviewed-by: Wei Chen Reviewed-by: Bertrand Marquis Tested-by: Bertrand Marquis --- xen/arch/arm/arm32/head.S | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 27d02ac8d68f..a558c2a6876e 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -93,13 +93,10 @@ */ #define PRINT(_s) \ mov r3, lr ;\ - adr r0, 98f ;\ + adr_l r0, 98f ;\ bl puts ;\ mov lr, r3 ;\ - b 99f ;\ -98: .asciz _s ;\ - .align 2 ;\ -99: + RODATA_STR(98, _s) /* * Macro to print the value of register \rb @@ -736,7 +733,7 @@ ENDPROC(puts) * Clobbers r0-r3 */ putn: - adr r1, hex + adr_l r1, hex mov r3, #8 1: early_uart_ready r11, r2 @@ -749,8 +746,7 @@ putn: mov pc, lr ENDPROC(putn) -hex: .ascii "0123456789abcdef" - .align 2 +RODATA_STR(hex, "0123456789abcdef") #else /* CONFIG_EARLY_PRINTK */ From patchwork Fri Aug 12 19:24:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E30AC282E7 for ; Fri, 12 Aug 2022 19:25:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385862.621688 (Exim 4.92) (envelope-from ) id 1oMaHU-0001hU-5n; Fri, 12 Aug 2022 19:25:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385862.621688; Fri, 12 Aug 2022 19:25:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHT-0001fu-Sf; Fri, 12 Aug 2022 19:25:15 +0000 Received: by outflank-mailman (input) for mailman id 385862; Fri, 12 Aug 2022 19:25:15 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHT-0001Zh-43 for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:15 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHS-0000yh-2I; Fri, 12 Aug 2022 19:25:14 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHR-0006n6-Qr; Fri, 12 Aug 2022 19:25:14 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=eGtlPOnezZCPLrLes6dERbD5TA/IOWPTENXfEX+3CEs=; b=6Te1Jx2dnT6deYglAWnLaUUau3 U/r15cOgOvWaXvMcF/a2mzL/7pyf8Rm4JGqCykyoOIXjqAcwWlGqtMDz0XdHLsceAKfT3bkQYD4v0 uOATOoul/JA3wyyWq3riti4jsIA1JPT+uXkQirm1j/5103YUwlLmCN5N5xgc4mu1b0NM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 6/7] xen/arm: Tweak the dump page-table walk output Date: Fri, 12 Aug 2022 20:24:45 +0100 Message-Id: <20220812192448.43016-7-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Currently the output is looking like: (XEN) 1ST[0x1] = 0x000000004015ff7f (XEN) 2ND[0x1f] = 0x00500000bfe00f7d The content of the entries are not aligned making a bit trickier to read (I appreciate this is a matter of taste). Align the values by forcing the index to be always printed using 3 characters (enough to cover 512 in hexadecimal). New output: (XEN) 1ST[0x001] = 0x000000004015ff7f (XEN) 2ND[0x01f] = 0x00500000bfe00f7d Signed-off-by: Julien Grall Reviewed-by: Henry Wang Reviewed-by: Bertrand Marquis --- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index b42cddb1b446..c81c706c8b23 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -234,7 +234,7 @@ void dump_pt_walk(paddr_t ttbr, paddr_t addr, pte = mapping[offsets[level]]; - printk("%s[0x%x] = 0x%"PRIpaddr"\n", + printk("%s[0x%03x] = 0x%"PRIpaddr"\n", level_strs[level], offsets[level], pte.bits); if ( level == 3 || !pte.walk.valid || !pte.walk.table ) From patchwork Fri Aug 12 19:24:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57261C00140 for ; Fri, 12 Aug 2022 19:25:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385864.621704 (Exim 4.92) (envelope-from ) id 1oMaHW-0002Au-6j; Fri, 12 Aug 2022 19:25:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385864.621704; Fri, 12 Aug 2022 19:25:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHV-00029I-UC; Fri, 12 Aug 2022 19:25:17 +0000 Received: by outflank-mailman (input) for mailman id 385864; Fri, 12 Aug 2022 19:25:16 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHU-0001lw-8p for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:16 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHU-0000z9-5C; Fri, 12 Aug 2022 19:25:16 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHT-0006n6-Te; Fri, 12 Aug 2022 19:25:16 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=iOLL1u2KoKBoa80MrMv6wujMJrVVx1Fxvbp2RjO3MMA=; b=f5qp8btfoRdImdkDqASaD7T85+ yj990o51158GqrHmrDZEDwMYd1ULtU8pkzcJy8NYeBrBcAqCHX3Ts2p1Ppw1jdv9HR+lu0EnvdCyQ 5PcKIr3v5TTdAk08OjvcQRJHoNGhxzUHr1bGhTYzlhBzSN8nxjnY4wQTAlIzTm7z5hMM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 7/7] xen/arm32: traps: Dump more information for hypervisor data abort Date: Fri, 12 Aug 2022 20:24:47 +0100 Message-Id: <20220812192448.43016-9-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Unlike arm64, on arm32 there are no extra information dumped (e.g. page table walk) for hypervisor data abort. For data abort, the HSR will be set properly and so replace the call to do_unexpected_trap() with do_trap_hyp_sync() to dispatch the error. Signed-off-by: Julien Grall Reviewed-by: Henry Wang Reviewed-by: Bertrand Marquis --- xen/arch/arm/arm32/traps.c | 2 +- xen/arch/arm/include/asm/traps.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/arm32/traps.c b/xen/arch/arm/arm32/traps.c index a4ce2b92d904..a2fc1c22cbc9 100644 --- a/xen/arch/arm/arm32/traps.c +++ b/xen/arch/arm/arm32/traps.c @@ -81,7 +81,7 @@ void do_trap_data_abort(struct cpu_user_regs *regs) if ( VABORT_GEN_BY_GUEST(regs) ) do_trap_guest_serror(regs); else - do_unexpected_trap("Data Abort", regs); + do_trap_hyp_sync(regs); } void finalize_instr_emulation(const struct instr_details *instr) diff --git a/xen/arch/arm/include/asm/traps.h b/xen/arch/arm/include/asm/traps.h index 08bc0b484c75..883dae368eac 100644 --- a/xen/arch/arm/include/asm/traps.h +++ b/xen/arch/arm/include/asm/traps.h @@ -73,6 +73,7 @@ int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc); void noreturn do_unexpected_trap(const char *msg, const struct cpu_user_regs *regs); +void do_trap_hyp_sync(struct cpu_user_regs *regs); /* Functions for pending virtual abort checking window. */ void abort_guest_exit_start(void); From patchwork Fri Aug 12 19:24:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12942494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2D60C00140 for ; Fri, 12 Aug 2022 19:25:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.385866.621719 (Exim 4.92) (envelope-from ) id 1oMaHY-0002bZ-2L; Fri, 12 Aug 2022 19:25:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 385866.621719; Fri, 12 Aug 2022 19:25:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHX-0002Yn-Iy; Fri, 12 Aug 2022 19:25:19 +0000 Received: by outflank-mailman (input) for mailman id 385866; Fri, 12 Aug 2022 19:25:17 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHV-00025p-CZ for xen-devel@lists.xenproject.org; Fri, 12 Aug 2022 19:25:17 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oMaHV-0000zS-6d; Fri, 12 Aug 2022 19:25:17 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMaHU-0006n6-V4; Fri, 12 Aug 2022 19:25:17 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=iOLL1u2KoKBoa80MrMv6wujMJrVVx1Fxvbp2RjO3MMA=; b=HV8AcaitSCtPNQGvgTR11HlGYd zs8drn6eNZQeqwFDC9Jp9OYpQgzrYGxLlwpxRXyIXXxhM7VSKQcQHfVC7dsWS8tuSjIiRYVIIEyav dG1AYdqaFUi3rl/H1v+22NiLoB2NqPLwEZPN6Nl6QBtjVbMsNAWenMdlAlS6ElSrwPdk=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 8/8] xen/arm32: traps: Dump more information for hypervisor data abort Date: Fri, 12 Aug 2022 20:24:48 +0100 Message-Id: <20220812192448.43016-10-julien@xen.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812192448.43016-1-julien@xen.org> References: <20220812192448.43016-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Unlike arm64, on arm32 there are no extra information dumped (e.g. page table walk) for hypervisor data abort. For data abort, the HSR will be set properly and so replace the call to do_unexpected_trap() with do_trap_hyp_sync() to dispatch the error. Signed-off-by: Julien Grall --- xen/arch/arm/arm32/traps.c | 2 +- xen/arch/arm/include/asm/traps.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/arm32/traps.c b/xen/arch/arm/arm32/traps.c index a4ce2b92d904..a2fc1c22cbc9 100644 --- a/xen/arch/arm/arm32/traps.c +++ b/xen/arch/arm/arm32/traps.c @@ -81,7 +81,7 @@ void do_trap_data_abort(struct cpu_user_regs *regs) if ( VABORT_GEN_BY_GUEST(regs) ) do_trap_guest_serror(regs); else - do_unexpected_trap("Data Abort", regs); + do_trap_hyp_sync(regs); } void finalize_instr_emulation(const struct instr_details *instr) diff --git a/xen/arch/arm/include/asm/traps.h b/xen/arch/arm/include/asm/traps.h index 08bc0b484c75..883dae368eac 100644 --- a/xen/arch/arm/include/asm/traps.h +++ b/xen/arch/arm/include/asm/traps.h @@ -73,6 +73,7 @@ int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc); void noreturn do_unexpected_trap(const char *msg, const struct cpu_user_regs *regs); +void do_trap_hyp_sync(struct cpu_user_regs *regs); /* Functions for pending virtual abort checking window. */ void abort_guest_exit_start(void);