From patchwork Fri Aug 28 13:39:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11742847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91F2B739 for ; Fri, 28 Aug 2020 13:42:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B60D207DF for ; Fri, 28 Aug 2020 13:42:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WjCj7rM3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c6+iYFm3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B60D207DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=X+cPLF/LiIfXKmTwKyPqLf2YCHxEm1JDpgTDzMoYcLA=; b=WjCj7rM3AhKBeWpjwTdy3oTi36 s4BS5zqY0YwnFt+BBFK38gO282j5wUWW/WKAR7yql72jNffcqZKC3XA3VFi+McvHnnjh5bjRinz65 lu26FOJivIw6Wl2LWbyyC9wkJfEH+4YlyMYLY+T42rtKkoMGeufVVUZ1sFDCFUqQ4G9FcG9mPgsPq mxzwxBuw1Duw5eH/tJaI6kXoguHa1mn/KdDK/qjgnKr0cBe8/Vk1GMXNGGBem+mpCG6NGCPCz17PE Hk3O069++fPR4RUigKyC1lvaBX4OBdubNPwlt9C9ZADK2gYyfQsrBjameJesf/F6e/+MEJhpQ4vbK Yz+UL6Dg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBec9-0000EJ-Un; Fri, 28 Aug 2020 13:40:21 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBec7-0000DZ-9j for linux-arm-kernel@lists.infradead.org; Fri, 28 Aug 2020 13:40:20 +0000 Received: by mail-pf1-x443.google.com with SMTP id o68so693311pfg.2 for ; Fri, 28 Aug 2020 06:40:18 -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; bh=mgrYv7djjcwPKBcwSuPRa9gDCJlsOXVcLbni56sIc20=; b=c6+iYFm39iM5ehnXHgohQOtvPP4Actfi+8FwijsEJLKpNxIw+zaMTTRVW5QuiVMSyK +uHvjVMeImm8j1nkGFFvBhdeq+mW57UR0mDt+TMCi9o1VA33Bazp32lsPKVyzGtFRgvU obaOn8bzO3sK6syphhgOp58IARzEs3BuHEOFKzvUJAiqUP1hzu9/W/LVB3XtKuVQRAmj SiSzWpgz0qVL4WxIFzNdUcaHUpYVzd5lp54gbDLZYbhovS7Bw9bEMWgT7xuWksJGMlTZ Om/ECbEvIuuQT/FFgjmIprCoeVjXm42xu3A44N/doEYtETaYrh66S2KBE98cOd48GXJu Dbtg== 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; bh=mgrYv7djjcwPKBcwSuPRa9gDCJlsOXVcLbni56sIc20=; b=Lun1+BfSp197p+2WjJUbgM3x7fjYJ7b4Y986DHq7H0VkPHl8YcpiaoIh9vDhRGD9GX Cn0IUQ9CExolcCiH25uPm5TcroHvjvByr8VCwHcSSa6dFq1jR+NMcJ2O23fwqxsg1q8R Qn2qg5K/hZMXh4JUx/7FsWcuSwxOpYxNzrbpG9fuduaKSrc+FcXjoBbNULOrL4Q4pj1H JUvUVi/fZPujkIHFaER1DvfmWSiXCviO226YE5SzHUw7X3VfsFcdWaaMCnHJVjai3qn9 K2aZ0r18rNNnDcyyWaq4wQoXP7yiNZ9Sr7xKBh79/x8m9CcS4gB3rcdyfFyBnh3ACT4c H83A== X-Gm-Message-State: AOAM530eNiMgyQVY+YcV0WwGUYb2Rtlg4WUJR/fYsEaZ0mWMnjfbxRAE 6x6tlYxCrLqsDhTH4MYALPblK9ervw== X-Google-Smtp-Source: ABdhPJwZ8ssnw7ayyRREkP1u9OCgsSNGyNfGZJQAc104tTnsMqU4PSmyX9pjBVp3Bj3pBJbEhvD1Kg== X-Received: by 2002:a63:1d07:: with SMTP id d7mr1349038pgd.106.1598622016873; Fri, 28 Aug 2020 06:40:16 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id k1sm1806559pfp.86.2020.08.28.06.40.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 06:40:16 -0700 (PDT) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 1/2] arm64/relocate_kernel: remove redundant code Date: Fri, 28 Aug 2020 21:39:57 +0800 Message-Id: <1598621998-20563-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200828_094019_354520_37901934 X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [kernelfans[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kees Cook , Geoff Levand , Catalin Marinas , Remi Denis-Courmont , Pingfan Liu , kvmarm@lists.cs.columbia.edu, Mark Brown , James Morse , Marc Zyngier , Will Deacon , Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Kernel startup entry point requires disabling MMU and D-cache. As for kexec-reboot, taking a close look at "msr sctlr_el1, x12" in __cpu_soft_restart as the following: -1. booted at EL1 The instruction is enough to disable MMU and I/D cache for EL1 regime. -2. booted at EL2, using VHE Access to SCTLR_EL1 is redirected to SCTLR_EL2 in EL2. So the instruction is enough to disable MMU and clear I+C bits for EL2 regime. -3. booted at EL2, not using VHE The instruction itself can not affect EL2 regime. But The hyp-stub doesn't enable the MMU and I/D cache for EL2 regime. And KVM also disable them for EL2 regime when its unloaded, or execute a HVC_SOFT_RESTART call. So when kexec-reboot, the code in KVM has prepare the requirement. As a conclusion, disabling MMU and clearing I+C bits in SYM_CODE_START(arm64_relocate_new_kernel) is redundant, and can be removed Signed-off-by: Pingfan Liu Cc: James Morse Cc: Geoff Levand Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Marc Zyngier Cc: Mark Brown Cc: Kees Cook Cc: Remi Denis-Courmont Cc: Ard Biesheuvel Cc: kvmarm@lists.cs.columbia.edu To: linux-arm-kernel@lists.infradead.org --- arch/arm64/kernel/cpu-reset.S | 4 ++++ arch/arm64/kernel/relocate_kernel.S | 12 ------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/cpu-reset.S b/arch/arm64/kernel/cpu-reset.S index 4a18055..37721eb 100644 --- a/arch/arm64/kernel/cpu-reset.S +++ b/arch/arm64/kernel/cpu-reset.S @@ -35,6 +35,10 @@ SYM_CODE_START(__cpu_soft_restart) mov_q x13, SCTLR_ELx_FLAGS bic x12, x12, x13 pre_disable_mmu_workaround + /* + * either disable EL1&0 translation regime or disable EL2&0 translation + * regime if HCR_EL2.E2H == 1 + */ msr sctlr_el1, x12 isb diff --git a/arch/arm64/kernel/relocate_kernel.S b/arch/arm64/kernel/relocate_kernel.S index 542d6ed..84eec95 100644 --- a/arch/arm64/kernel/relocate_kernel.S +++ b/arch/arm64/kernel/relocate_kernel.S @@ -36,18 +36,6 @@ SYM_CODE_START(arm64_relocate_new_kernel) mov x14, xzr /* x14 = entry ptr */ mov x13, xzr /* x13 = copy dest */ - /* Clear the sctlr_el2 flags. */ - mrs x0, CurrentEL - cmp x0, #CurrentEL_EL2 - b.ne 1f - mrs x0, sctlr_el2 - mov_q x1, SCTLR_ELx_FLAGS - bic x0, x0, x1 - pre_disable_mmu_workaround - msr sctlr_el2, x0 - isb -1: - /* Check if the new image needs relocation. */ tbnz x16, IND_DONE_BIT, .Ldone From patchwork Fri Aug 28 13:39:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11742845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE3C8739 for ; Fri, 28 Aug 2020 13:42:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B79A2207DF for ; Fri, 28 Aug 2020 13:42:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tXfMufzs"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="klaFOwH0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B79A2207DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4kTWtQXDb4Vm29llXbUy0jPGhhMuwHQIxG1DpQ6PnZU=; b=tXfMufzsCs7En2of5KHaY+wTjE azqeUO/3kCWpzuGS7pwTk1tJ4MkvAtp5WaGCrCtS/onio9h5i4WEPJxaUqTF5XK/hu1PhkPWkQHDh 5qugHxgdZz2kEBjmoh3bzazNdoqy9lGIwYkFjAQ+RSeWmuFXE+hN4ZNP+lxsRVklb139Uh0xCMSlw lDGypLM0iXGNwp/IegMM3gP2zGj4/Oz8E2H8ENg2QgPnguTnJREyiDFo6yAt9Rv2GPJ+Vg+kuqpTs scoI/W7xLc6KOvheTqTCA1ZqaQ4++NNNFhlIjt15ILsA2EDslG6qLHKkb2esnQgPGyuuSQhZsbFLS TmMavuHQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBecF-0000G0-Nn; Fri, 28 Aug 2020 13:40:27 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBecB-0000ES-VH for linux-arm-kernel@lists.infradead.org; Fri, 28 Aug 2020 13:40:24 +0000 Received: by mail-pf1-x441.google.com with SMTP id d22so683861pfn.5 for ; Fri, 28 Aug 2020 06:40:23 -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; bh=FG3XCoXB/aty+ooJaX6AfmzW3u7+uhF6LOoAHszXFMo=; b=klaFOwH0ElHAR7McpnZD67Y7Y2E4ysRVd65Eh0X8Xr9Z5ZyWbIBjWtyCrwOB4Od/DA XRJMjfQSPlBZrjbgkR+aWt+dMTPdm3RfYYKFYmMffLNpvXiND2Idjh7oautoaA2MYL+q /aMHMhbMTXmSQQM3HOmFP7V4IB7vdF95uncZUymzdTq0dWQt129AmStxuUL6cEE+bT4X ToHwNGA6N4Gj9pNw6HzkGUknEsJK+o2/5MFoKW275e2o2HRQHyMHs2gDiU2W4mbgmwCP XasIdGHL8WGH0oaEbsJ7Xh/05/Dwf1tS5KwbhE/Qhy1BOMowRz0YOo1D2uxsKLKSaOvR A8ZQ== 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; bh=FG3XCoXB/aty+ooJaX6AfmzW3u7+uhF6LOoAHszXFMo=; b=BiBBLYPmdFwNSzwQlL+1jd8O860VhG3Y0lUN4jkRhUNe4ODsS1MhwxUMpCJa9/C0p8 SgN+Ssg81j6WjP5hWdPqA53Ka0UDG5iPFjEsa/faFWONcwXfNAYUdgIoB9ThWbWjwkzr 19Txt/r27NfR0r3S8p0b3OTtS9dQHMSdxO/kyjd0hv8kaj9wG5A2HQC+A46rxkcvMof/ tQaHSh9YVssEVSqUmBhA0N4dL8xYgo3RduwSPMA4nrlr0aOHH1271rOgSnW1bVrBlhxh ++ztBlcS3FXV2Kj7dnIL5SAkwhpO7Y2gjnnhXY6CA92CAAT9aou/h6dBVR6J24jUxv7Z X7qg== X-Gm-Message-State: AOAM531oMmMSNcYKHUPCjN3iOCc49i3ONef0vk9uH94IPXZLiT0imqmj rlohUQfpiBejeQ4NS1rCb4TZbJqBlA== X-Google-Smtp-Source: ABdhPJwM7vdnpfEicNNMs9GsRsbhv34l6T2Wg0n67dn0Hmq86jCu4vPZ+wdNmQARVjSSpiwV50Risw== X-Received: by 2002:a63:b10a:: with SMTP id r10mr1314017pgf.431.1598622021821; Fri, 28 Aug 2020 06:40:21 -0700 (PDT) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id k1sm1806559pfp.86.2020.08.28.06.40.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2020 06:40:21 -0700 (PDT) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 2/2] Documentation/kvm/arm: improve description of HVC_SOFT_RESTART Date: Fri, 28 Aug 2020 21:39:58 +0800 Message-Id: <1598621998-20563-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1598621998-20563-1-git-send-email-kernelfans@gmail.com> References: <1598621998-20563-1-git-send-email-kernelfans@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200828_094024_054720_A37D6960 X-CRM114-Status: GOOD ( 13.71 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [kernelfans[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Suzuki K Poulose , Geoff Levand , Marc Zyngier , linux-doc@vger.kernel.org, Pingfan Liu , James Morse , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Besides disabling MMU, HVC_SOFT_RESTART also clears I+D bits. These behaviors are what kexec-reboot expects, so describe it more precisely. Signed-off-by: Pingfan Liu Cc: James Morse Cc: Marc Zyngier Cc: Geoff Levand Cc: Catalin Marinas Cc: Will Deacon Cc: Julien Thierry Cc: Suzuki K Poulose Cc: linux-doc@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu To: linux-arm-kernel@lists.infradead.org --- Documentation/virt/kvm/arm/hyp-abi.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/virt/kvm/arm/hyp-abi.rst b/Documentation/virt/kvm/arm/hyp-abi.rst index d9eba93..83cadd8 100644 --- a/Documentation/virt/kvm/arm/hyp-abi.rst +++ b/Documentation/virt/kvm/arm/hyp-abi.rst @@ -54,9 +54,9 @@ these functions (see arch/arm{,64}/include/asm/virt.h): x3 = x1's value when entering the next payload (arm64) x4 = x2's value when entering the next payload (arm64) - Mask all exceptions, disable the MMU, move the arguments into place - (arm64 only), and jump to the restart address while at HYP/EL2. This - hypercall is not expected to return to its caller. + Mask all exceptions, disable the MMU, clear I+D bits, move the arguments + into place (arm64 only), and jump to the restart address while at HYP/EL2. + This hypercall is not expected to return to its caller. Any other value of r0/x0 triggers a hypervisor-specific handling, which is not documented here.