From patchwork Mon May 9 16:25:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12843851 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D8546C43217 for ; Mon, 9 May 2022 16:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kFMQ1e96OKiETlVNTRvMRibmaS5WGumDbM0tsNKn+nw=; b=jYUe7WDBxXlrWf41RBmYNKbr6h gsjMMDnuou/BjHES8BkWjrvl+Zrs31wbzJ1QcDihUCfQfkesa+bjkNBCaSA7WNk/ISR6Ycdh73gp4 NcOzh46rD3NsApJEYHWV28ARc5ycP8iL6ZtReJeW3vs92t438caK92jAwkdyLgpX2LP4a0bHGZ/wd cTUaFdv/DypAAMnwPNxQX8Dnl21D09uTZYFKou2HzTYRz9Uu7jUamqXo+F1C41zwi2qLQpDP747JN IPOMkbTFPx9/cq4HRPr/fZ9y1i059LTmgXlmvVsz84XapYcu8s4MwGUntDO6HAkIXN4Jz4EFSr9Bc +p62APUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1no6DL-00FORJ-Uo; Mon, 09 May 2022 16:26:28 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1no6DB-00FOLr-LL for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 16:26:18 +0000 Received: by mail-pf1-x449.google.com with SMTP id x16-20020aa793b0000000b0050d3d5c4f4eso4946018pff.6 for ; Mon, 09 May 2022 09:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ramO0+cEkxqJX3F8coHgv6jkuFbFeK102oolsavMu20=; b=dzr2hls94IW3ClUuA2BSr4qrrnhWvuyEZI8nmXUIdiJHGzCNV42d2pewDNyyq80z8v bWsUx/m5Ue/BW1YKhvz5ey2N7GtbjeXfSalL431rTrIhm9CbPH2N7m/FTSxFsyeD3qUp vXJqArAH9zH6NJ6jgi3AYOdxSAZQ/zZ5hPibtfe7o8lwCwTgu6Cz50/+wdJ7XGjzpShB ARsg0FK+LbtIxB0pYfEVUWq8IWxV5K/BYzouxazPSfK7emCZnaAacA2ohaNp1x+3aIGa jyR/0vEsVlbDWN+XzL8wXDCFCcrU9hSGVTMq87y7rn8FTavQQDuIBOI5u0j2wnP/e64n LqNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ramO0+cEkxqJX3F8coHgv6jkuFbFeK102oolsavMu20=; b=leuARCtjzhbGn1zhQUkC9a/PpDMPLgrQaHY0f+Jq3cAocsps1DjKWvST5N+lfbEtPA XhTbNR2oTZfQDYnltlJfgqMHPLMeX2sMHcpTfntcddX4U0qQpNolAycxh9SFZaAVRcyK bRxcshZD4/hFLt/G9jQdZwUdw8T0ae6Tu5dvXZMFvsZG+P7yIK2zrEBDAJ71QewBNDXg 7VPrDoFM5FkqEMhx5Us9eYtVJ3rvQF+7U3D/LyN8wfcx04q4rX8aZ4hRw1OmbdnyshiZ bSGNke85Mqrxq+2Ma9cvgF7DT9hRHvB+fnWM8AXpVID3VUmnjXJXzGfEQxCqAvVO7P5P cEvQ== X-Gm-Message-State: AOAM530YqMO25EMXyfiN5t+rAvTDnhIJw4gO/e4wyXwNVhgCcq14R9MQ 5YYj5kPrRFF6X9ZTM7RcT/6VtS8bSQ0= X-Google-Smtp-Source: ABdhPJzdjvmm33Xww7qbolbHONdNzfLPiXVqOOHjncbxPv2g5srfZyPR6YVyWtFPJJJKmTvTXT956abVHGQ= X-Received: from oupton3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:21eb]) (user=oupton job=sendgmr) by 2002:a17:902:e74d:b0:15e:94f7:611e with SMTP id p13-20020a170902e74d00b0015e94f7611emr17008035plf.37.1652113574927; Mon, 09 May 2022 09:26:14 -0700 (PDT) Date: Mon, 9 May 2022 16:25:58 +0000 In-Reply-To: <20220509162559.2387784-1-oupton@google.com> Message-Id: <20220509162559.2387784-2-oupton@google.com> Mime-Version: 1.0 References: <20220509162559.2387784-1-oupton@google.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, tabba@google.com, qperret@google.com, will@kernel.org, Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220509_092617_734336_AED69505 X-CRM114-Status: GOOD ( 12.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pVM-specific FP/SIMD trap handler just calls straight into the generic trap handler. Avoid the indirection and just call the hyp handler directly. Note that the BUILD_BUG_ON() pattern is repeated in pvm_init_traps_aa64pfr0(), which is likely a better home for it. No functional change intended. Signed-off-by: Oliver Upton Reviewed-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/switch.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index 6410d21d8695..3dee2ad96e10 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -175,23 +175,6 @@ static bool kvm_handle_pvm_sys64(struct kvm_vcpu *vcpu, u64 *exit_code) kvm_handle_pvm_sysreg(vcpu, exit_code)); } -/** - * Handler for protected floating-point and Advanced SIMD accesses. - * - * Returns true if the hypervisor has handled the exit, and control should go - * back to the guest, or false if it hasn't. - */ -static bool kvm_handle_pvm_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code) -{ - /* Linux guests assume support for floating-point and Advanced SIMD. */ - BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_FP), - PVM_ID_AA64PFR0_ALLOW)); - BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_ASIMD), - PVM_ID_AA64PFR0_ALLOW)); - - return kvm_hyp_handle_fpsimd(vcpu, exit_code); -} - static const exit_handler_fn hyp_exit_handlers[] = { [0 ... ESR_ELx_EC_MAX] = NULL, [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32, @@ -207,7 +190,7 @@ static const exit_handler_fn pvm_exit_handlers[] = { [0 ... ESR_ELx_EC_MAX] = NULL, [ESR_ELx_EC_SYS64] = kvm_handle_pvm_sys64, [ESR_ELx_EC_SVE] = kvm_handle_pvm_restricted, - [ESR_ELx_EC_FP_ASIMD] = kvm_handle_pvm_fpsimd, + [ESR_ELx_EC_FP_ASIMD] = kvm_hyp_handle_fpsimd, [ESR_ELx_EC_IABT_LOW] = kvm_hyp_handle_iabt_low, [ESR_ELx_EC_DABT_LOW] = kvm_hyp_handle_dabt_low, [ESR_ELx_EC_PAC] = kvm_hyp_handle_ptrauth, From patchwork Mon May 9 16:25:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12843852 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B81A2C433EF for ; Mon, 9 May 2022 16:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NHQQju+ylQwE3ozcHyahaLRVSj52ITRcKNXSnrpy4Pk=; b=oW81qAhn+m+8D1q211YD06QYrC 8udknUlN2zeGxHp5AeiqEupOddRVZ4PpaxjVY1C44YkfXBwP/QpaJPhz2/jGyuS3WtPamBW6USRLb A17hBVHfm/LsNB8fgLsMo3ZQMtsRGyH+FV9wu031R9uK3vnZRVZCg9p2bEFXZKf0vDC9Rn3Fu9uCL Q2Wz7pYjxhKYpj3knrYF2fIIhicXHd8sWVN0actqt22IGzj44xz2MPUYUvAWEwKWWjQ0tIEX4fW4B lfP+vP6/JY1FvKNbARMiVbeVhIcFaD1CM4OWwRQb9AUuFIXlnEpLLHNwMynMiTjAaLxp2Yvbwvm3R ZgsBjG7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1no6DU-00FOY3-IW; Mon, 09 May 2022 16:26:36 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1no6DD-00FOMT-CU for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 16:26:20 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f7c011e3e9so124684557b3.23 for ; Mon, 09 May 2022 09:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xGoqp6X+CPpEHo725m8Wu+g1erF1chW9bMEShQucuQI=; b=N0Zb4Gxa4HC1uAASPa5PNvN6IZjx7J7GkqJJxcHMPKOV18yjIl3pcEmceZOJesdcnG QyYuP15OLQgQAzxZvOx9T/u4IcSod9jZabxpWQQRxegBDjAddti9A+I5FItlHEwguaJN TpTsFWnpbz8e2DrUL88byAshOTHwqCzr3yK86hOE/LVy9b/KYkpySe/p+6GKXer9+ZsT AJn8WeUun7zv6Aus63gh3Xr1mdIhrS9YxFDp64pMHUMFpR3ooGR2iVg+ijhT2AzXWlvC 0smRDvmncy7dBiwIBRAlq8Ds4xGlgiZR/k0QeJkvUFeyICFF+QBvChLD1FP9jVkilG9n 6zEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xGoqp6X+CPpEHo725m8Wu+g1erF1chW9bMEShQucuQI=; b=acZsN4XeuwEfmIjiEn1G+UpSTYHfyyYWkLRGzIvClRFWSPuqiJ89e/nMPGj9++Ly2t aeNoBl94WCy8k3hSqA/lFLJA8RD+dvVcjz0F/Q2oaVi5K+yQCXVL9drN2uP0d7UzPjPB OOnNMORVQUvfIPQkOVQ5AiLooRlynLxTv6l45xs98lk91xkjWKUFpZPNMcLirDp5bAY4 k+JvDfNgsPTQHL3Dn9Ao4szm7J4BaWUy0TeqbW7hj852Y2FLqPY4PSueJCJdow4BaVZk NS1xvmj+GNCsggw+SLev0QcP9MVg3LSbjzpm1bFfQeHxvN8cJSF8d2N8A4Ec0tgE78Hr peBQ== X-Gm-Message-State: AOAM533uKfPsUVD6uaxp1UiqGbatGOobnWs25QN23F5b3ZeG0g0uFdOm WF+oSHpTdPN2u8E6+8xIaZV4Pi0xZBE= X-Google-Smtp-Source: ABdhPJwbEmmNk02jHZlxW+mCJH3BMBXB3kvXc9tx+Zc+AF6gVkBuuuHex37mMcuOHpy47pgj2Z6U4qDyQ2M= X-Received: from oupton3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:21eb]) (user=oupton job=sendgmr) by 2002:a25:3157:0:b0:649:b216:bb4e with SMTP id x84-20020a253157000000b00649b216bb4emr14278182ybx.387.1652113576747; Mon, 09 May 2022 09:26:16 -0700 (PDT) Date: Mon, 9 May 2022 16:25:59 +0000 In-Reply-To: <20220509162559.2387784-1-oupton@google.com> Message-Id: <20220509162559.2387784-3-oupton@google.com> Mime-Version: 1.0 References: <20220509162559.2387784-1-oupton@google.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, tabba@google.com, qperret@google.com, will@kernel.org, Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220509_092619_466648_C2048C46 X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org FEAT_SVE is already masked by the fixed configuration for ID_AA64PFR0_EL1; don't try and mask it at runtime. No functional change intended. Signed-off-by: Oliver Upton Reviewed-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c index 33f5181af330..3f5d7bd171c5 100644 --- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c +++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c @@ -90,9 +90,6 @@ static u64 get_pvm_id_aa64pfr0(const struct kvm_vcpu *vcpu) u64 set_mask = 0; u64 allow_mask = PVM_ID_AA64PFR0_ALLOW; - if (!vcpu_has_sve(vcpu)) - allow_mask &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_SVE); - set_mask |= get_restricted_features_unsigned(id_aa64pfr0_el1_sys_val, PVM_ID_AA64PFR0_RESTRICT_UNSIGNED);