From patchwork Thu Dec 14 10:01:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492685 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 6B33DC4167B for ; Thu, 14 Dec 2023 10:02:42 +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:Message-ID: References:Mime-Version: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=1xa8PNuJnZaE/BEbCqTxwscZhmn2HokWZzCRb2ruKdw=; b=ub9FOQGY5UGlL/gGjzjN7MLCcd MIPTwkOncIp2W5fHVK2I232BBakmFhghSCqkzhnbPXQYJfLGTK1O5DaZcMdayM0gWtvnK2iI0AfCU KU4O1twAAD5diruJt4xN/e/X+x55DPV1hJ9Sa15IDkFG3tknZkeDKwI/CR92DFu3anprLnR9t/hw4 wQ5RvEnXDpqpHw+JXjuKLpFmBeuMN9CIN3ej9AVkbqTkc/lOETOhrBUVWEVi9KbOPPMxOw3ca0bSt UmhjTTqRdQZiTAYwT7bOxVtXYlBQ2IwASja8uWU9t/wFbbkhuayqnUAEjWUvHrBi0ToZaJf3Uesdo ZByKMEfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXj-00HOrV-2N; Thu, 14 Dec 2023 10:02:11 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXd-00HOom-1D for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:06 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3335df64539so6583893f8f.3 for ; Thu, 14 Dec 2023 02:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548122; x=1703152922; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lK/UD9rywANKR7blVX9d/xN+XkoswxGXvB4reNM2bgU=; b=BerM1LdGYAQ0VcB50tC+ISD7XEeD7vO0LgPOxrlL6nQ49llYq14lEpGBsddB4h82hT d+hAXBBc8jc5AffkL739tnYIrATBgp+Q1OtCEgQ2TmU675GFRmEEHJyeAtbPQIvS/8Ue zyclyWH1ukyeD4L4LY5fSe5uxGy4+a0Mh0fQo4ILXQWh9ivJ42kSk3bsQCJeG31lJAKX joLMFfwSfTMASJakoIZkKQ560mVsz31XQCe3P2ldjwqM+tLXFIVNq4RKLalvYv6bV4Gv 8YAUehSukK1U5neejYbxPCmsYN2HXRlEdmsgHsIuKXYaSWxuAwHA9/AEBFfAcixldDbA YFyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548122; x=1703152922; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lK/UD9rywANKR7blVX9d/xN+XkoswxGXvB4reNM2bgU=; b=XbuOsMmB7vRY1N9YBwjAWtnDeCsNCC8N/uTvMhDZgM7j1fDRKa1Qc1fDJ1VfATqvKt Hpqx6tnQAUf1N/4NRb8VM5MyhihRkQUcSGJA1vg/PBmHWSfWwPINW4tnAjjXVViuTIw0 Jf2jnaPh7TehcOrHcy00zRmq16SBfUm2W8NKmqX1K7B/W+KA20KW5/hvcr+7fWtZbOi2 h3H4S/f+0jSciP+0OKRIS3P7W4Ai1tIDD3NfPcbVog+9uOYecF7AI/UdaRrGoMpAiF23 3iF9dTlDQVljMf/9RB9atlmdC8+JvIJzhLgJ1apCFVdJ9HS5pU8x7QlBx9Fs5TF/DJ+y JPtg== X-Gm-Message-State: AOJu0YzI+g6wWYIiG3wqCQ2Mvikb3yBifHxe7Ec2+MJlZQ5IlmYgu4Yg SPnuibEiqz0D3PVZk+ZB5j2CnMrn2w== X-Google-Smtp-Source: AGHT+IGJJHIsD1xjhl63UW9V8Ndxpk7q0cp06ihFUj9uAXgwk16GOxymoaVfreWidlYvo/hi+CCyO8rG8A== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:adf:f2ca:0:b0:336:471e:ada7 with SMTP id d10-20020adff2ca000000b00336471eada7mr4618wrp.0.1702548122478; Thu, 14 Dec 2023 02:02:02 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:41 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-2-tabba@google.com> Subject: [PATCH v3 01/17] arm64/sysreg: Add missing Pauth_LR field definitions to ID_AA64ISAR1_EL1 From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020205_411850_110B6EF1 X-CRM114-Status: UNSURE ( 8.66 ) 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 Add the Pauth_LR field definitions to ID_AA64ISAR1_EL1, based on DDI0601 2023-09. These fields aren't used yet. Adding them for completeness and consistency (definition already exists for ID_AA64ISAR2_EL1). Signed-off-by: Fuad Tabba Reviewed-by: Mark Brown --- arch/arm64/tools/sysreg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index 2c4b6665c5bf..d596be2599d1 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -1401,6 +1401,7 @@ UnsignedEnum 11:8 API 0b0011 PAuth2 0b0100 FPAC 0b0101 FPACCOMBINE + 0b0110 PAuth_LR EndEnum UnsignedEnum 7:4 APA 0b0000 NI @@ -1409,6 +1410,7 @@ UnsignedEnum 7:4 APA 0b0011 PAuth2 0b0100 FPAC 0b0101 FPACCOMBINE + 0b0110 PAuth_LR EndEnum UnsignedEnum 3:0 DPB 0b0000 NI From patchwork Thu Dec 14 10:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492683 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 86E03C4332F for ; Thu, 14 Dec 2023 10:02:38 +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:Message-ID: References:Mime-Version: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=kojimgzE7EQApuK0vG7Le2c3PLGgmcr8jTdBGpdpSV0=; b=QTTwE4bU+iKxCimt9pf0V/X4Xp G9MJGU09vYo/H3yLmQ+ga055fLEQ1DE0KTxEiYwMYiquEQ9TmmGcfUJMytQ0uPYUqjWuDTPrZzg0A Jq0SkzszE3NcKJ3z4Riod5Q4XZRofRw7Lh66uqLFqtIwbfpJFbVdk42LTpKusFURHprZjNnD3y2G1 LllVElWE1hcSYSpGF7DF/3OwdQt+whMfVR/I/ySaCvZa9+0h8dFfAqJJMdUpGG1Kv9gFYj5io29CD hJMdWW85X6IPl4M1hR1PPyEueHnB9PE5LCIhRTgV3cTUQNzdMyu9tN7DiWoypIiBazzBjCMWAzGmf 5i9BViwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXk-00HOrp-0x; Thu, 14 Dec 2023 10:02:12 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXf-00HOp4-2A for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:08 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3364a99b38eso122519f8f.0 for ; Thu, 14 Dec 2023 02:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548124; x=1703152924; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TguY2CRPZsDbC7EwriWWWSxwKPNn+kyygMIufDgE984=; b=IdfJzNl3WaViYwYy32DWMRYsEtNszL7H/rHg47HfD3ShnEEjdCky1ZKCv4vguhuUkg DJwY16z2QiVhs+76w/Q1yTZ40VMjpd9v4td7PQyINysyVnwlUdDwETsrmWT4I+tjSmds YS/SmNHMVBa/RBLJ24HMOUQAFJucR8+OHw+9jcuts7sZprcFLpPEdtk2rFceg4D30++i IbHrUfjoi//mvm0tmetfXDk+SHgQX4WNlP2gqsevDEkk1grAnWaOEK+F3Udga2aPNpHW DZY+EN+VGtDOjzz4ACTQ8EdhZ6ZhCtncCoQMh+w01LnzkVNIe/jQcD4bhiMGYmutnILO 0wrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548125; x=1703152925; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TguY2CRPZsDbC7EwriWWWSxwKPNn+kyygMIufDgE984=; b=QvIJXZpgkoRoaW0G9dLNNi7f4v8Dc2oPrRoskHRCMx6/anF1Qrzr3QbE3ZJgq4E/op RZa/JoMRxsdpB9akyplRKCd9VjLnqtNwgHKYJ98mPzInYckRnOx0fyg4RdUj/83o4gjK T/S5Fx8Phs5Pbdwm8nqY3dkxu32FJm+ibFyT/ovdO/7A3ZK5PhLAUnyHEyB7bfZdxaSC 5CoeS3ZTeKsHt8SeaiiyRPd1CLfUEWTAuqjXX2ebqkZCiPrG4k85sTskuCaLryj2PwCf RlOFLS5rTTLyaCa87KQ+CkHErMav+ULO1JRyV2PlISH1fzXvw//byCjnHh1+5livAN+a xC/g== X-Gm-Message-State: AOJu0Yw7FLHlKl28djTDXw9A2KxwsPbI9uSgfB4qcZ5+X673jBg9pt7i 8HPEiWMEp0vBwU/Y6YcA2MMdCrA/wA== X-Google-Smtp-Source: AGHT+IEzmFHlBxyZF8O+LbvH0QlS0e2LiJp8Xgrv+Xa+5a0SbCpGGf2FmJL17DH3UiYhv0VTN7gqNhALtw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5d:6daf:0:b0:333:543a:9f9b with SMTP id u15-20020a5d6daf000000b00333543a9f9bmr52179wrs.11.1702548124858; Thu, 14 Dec 2023 02:02:04 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:42 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-3-tabba@google.com> Subject: [PATCH v3 02/17] arm64/sysreg: Add missing ExtTrcBuff field definition to ID_AA64DFR0_EL1 From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020207_713150_B4B99091 X-CRM114-Status: GOOD ( 10.27 ) 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 Add the ExtTrcBuff field definitions to ID_AA64DFR0_EL1 from DDI0601 2023-09. This field isn't used yet. Adding it for completeness and because it will be used in future patches. Signed-off-by: Fuad Tabba Reviewed-by: Mark Brown --- arch/arm64/tools/sysreg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index d596be2599d1..a8e36640c027 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -1189,7 +1189,10 @@ Enum 63:60 HPMN0 0b0000 UNPREDICTABLE 0b0001 DEF EndEnum -Res0 59:56 +UnsignedEnum 59:56 ExtTrcBuff + 0b0000 NI + 0b0001 IMP +EndEnum UnsignedEnum 55:52 BRBE 0b0000 NI 0b0001 IMP From patchwork Thu Dec 14 10:01:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492686 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 04D25C4332F for ; Thu, 14 Dec 2023 10:02:44 +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:Message-ID: References:Mime-Version: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=amV3EIQiZ2+KK/vx8XytZ1Q6Y/cxASnwqCypoOfi8U4=; b=00aBc4+eZaQfDBYR3URbMZMgEm 7PqiKecRJbUy3bAQOn0aazzw5CLd6fY+zlwQi7fDkPd8owhOGmZ0cLmJUsX2XLH4kYCTDVjoIKfZx uXGKloRwbRQtMT4B7uGLL3L9/Nt2pAJv5pDldum0NXkOnX04sWIEer8HqFkrFpM5CyX5jCwKh/mZc j8Q7GuFG83753Ai34Htk+zpVWUIQp37L8JGNEzYy42xM6AgeWQM5Wt7Cz0eubD9b/0xowpPSVE/DW Q+iX8ldP9ognlcpkjb4n1MluUn2UAmtPUPACrSgMZQVaAGoMe1dkZ6Ty2PHCzHDl40L5LqkbFaFeI eFRHrarg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXl-00HOs8-0k; Thu, 14 Dec 2023 10:02:13 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXg-00HOq2-1x for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:10 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9a541b720aso8493694276.0 for ; Thu, 14 Dec 2023 02:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548127; x=1703152927; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cL1RM+olJsmQC3rlwUz51qwzObdNnMoFgRZbOyilRC8=; b=xtwvP8OnNzTd3EQ0JAy7tvhvtMD2tKMGeKIEFWW+E14z7/j8Cxqf9cZ8NIo0YYc6CD HbhyMnR6o4WBRSs2JAX2DQYYcDP+0dnv5Pz9c/JDGnz2RS9UWbp0CjKGZnkR0VXNq53J BqAS1nrSZo7oF4Mzax/aywGPeeXnMJj+48yC7K+o91cpdXiAe6ovJFfAwwg9qWGCKAAC pau2rX7VxV1PT7EhVAiSxX2SWAWqBbhNmdehbzqHeGr4wFazXDhb2He+IP7YaYhTRp64 s5/gGKGWgDpNV+ey5xB2cedEktPR8z/TfAlRQ1Y6CxqhYSSaYmyDKe0RFP1Nxe6+YK22 miAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548127; x=1703152927; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cL1RM+olJsmQC3rlwUz51qwzObdNnMoFgRZbOyilRC8=; b=ehA7anBiwviH9KwrfEuHIlJJzWjtfGbptjqqo1dhh/YRfScGVZTTl4XuggBE+g+fkH itlnrUnslNdX8rk+lOM5/N0szPPVf+591jB7ew95WDupHPzkTJWeYTGN0gQxXq7R+RWI 21ZugP6ipAGQXL95SQsqe4oiks2OYzlFolF7+72cv382TOh7LrVkqAHghckzr2EK3Dmt LnBnoqlKWmvuvfMhb3yAepJKzVJgdhBuC7uqbKfFN+z/Hd0cYJ55zGFR2PmTtRK4OSfI adxyfy8L7/Kyi3JAYEHlH0CFi3HcmjY77QNvb0W6Dm4SSWb26UCz2SeKwFsGHxMii0zz mUqA== X-Gm-Message-State: AOJu0YzpQetHhnBkidFod5Ukz2mum6ZkXHD7KH3o5Bogccjz+N99NJfl EkLhK+vqfDCp20eg7n/oSO+Q+qNnow== X-Google-Smtp-Source: AGHT+IFdf/kGRovY/XOsMBonsCGOYiqd3rLc8nEiGw7C7DJypFe2aftCAYaDZMQMTm3AeDZLmHSSwTzk5Q== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:345:b0:dbc:1b7a:e185 with SMTP id e5-20020a056902034500b00dbc1b7ae185mr80924ybs.8.1702548127111; Thu, 14 Dec 2023 02:02:07 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:43 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-4-tabba@google.com> Subject: [PATCH v3 03/17] arm64/sysreg: Add missing system register definitions for FGT From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020208_646103_6ADB857F X-CRM114-Status: UNSURE ( 8.16 ) 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 Add the definitions of missing system registers that are trappable by fine grain traps. The definitions are based on DDI0601 2023-09. Signed-off-by: Fuad Tabba Reviewed-by: Mark Brown --- arch/arm64/tools/sysreg | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index a8e36640c027..5ceaa1d3630e 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -2086,10 +2086,18 @@ Sysreg CONTEXTIDR_EL1 3 0 13 0 1 Fields CONTEXTIDR_ELx EndSysreg +Sysreg RCWSMASK_EL1 3 0 13 0 3 +Field 63:0 RCWSMASK +EndSysreg + Sysreg TPIDR_EL1 3 0 13 0 4 Field 63:0 ThreadID EndSysreg +Sysreg RCWMASK_EL1 3 0 13 0 6 +Field 63:0 RCWMASK +EndSysreg + Sysreg SCXTNUM_EL1 3 0 13 0 7 Field 63:0 SoftwareContextNumber EndSysreg @@ -2714,6 +2722,33 @@ Field 1 PIE Field 0 PnCH EndSysreg +SysregFields MAIR2_ELx +Field 63:56 Attr7 +Field 55:48 Attr6 +Field 47:40 Attr5 +Field 39:32 Attr4 +Field 31:24 Attr3 +Field 23:16 Attr2 +Field 15:8 Attr1 +Field 7:0 Attr0 +EndSysregFields + +Sysreg MAIR2_EL1 3 0 10 2 1 +Fields MAIR2_ELx +EndSysreg + +Sysreg MAIR2_EL2 3 4 10 1 1 +Fields MAIR2_ELx +EndSysreg + +Sysreg AMAIR2_EL1 3 0 10 3 1 +Field 63:0 ImpDef +EndSysreg + +Sysreg AMAIR2_EL2 3 4 10 3 1 +Field 63:0 ImpDef +EndSysreg + SysregFields PIRx_ELx Field 63:60 Perm15 Field 59:56 Perm14 @@ -2765,6 +2800,14 @@ Sysreg POR_EL12 3 5 10 2 4 Fields PIRx_ELx EndSysreg +Sysreg S2POR_EL1 3 0 10 2 5 +Fields PIRx_ELx +EndSysreg + +Sysreg S2PIR_EL2 3 4 10 2 5 +Fields PIRx_ELx +EndSysreg + Sysreg LORSA_EL1 3 0 10 4 0 Res0 63:52 Field 51:16 SA From patchwork Thu Dec 14 10:01:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492691 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 71EE0C4332F for ; Thu, 14 Dec 2023 10:02:59 +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:Message-ID: References:Mime-Version: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=bfx2z0fYdrACEsPwQDI360TneSmrbmscsQkWxbxkmMU=; b=293tvcoI9a+QmnNUZtK4pFrbR/ lP9EE97/QhYhNqgUOEz1ICr4VgGLEsj0ANLT7u6TQGBS9BgjyWoztBCr88Iug+eg91eewxgxtVxCn FhTRZBazqH0zECL+sLSvQezz9AojLWNm6C2Ycm75UnUA1cXC0n3Mtd4GnxnHjlPxjpM7w1LEcMIWf /GOtzPyVNcaZNJ3Fd5rf3PSQMlgL0Uuq7qkZNy1AxbT4hyG2h/dRh0zJWLplzyN32+NSvoVoJN/wx xzCC0286jexsNHjyigvUZQDUxUYQ074zFP1+QhT77OvrMq/0fNRl7KzqTVevu8QwFy3A5TTIrWSJx pqZZ87zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXx-00HOwW-2U; Thu, 14 Dec 2023 10:02:25 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXi-00HOr9-1n for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:11 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-db402e6f61dso8476221276.3 for ; Thu, 14 Dec 2023 02:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548129; x=1703152929; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WrUatI3Cz0L0l26hy5tOUKXSSgihHrtUAipqZf1EAmE=; b=XBxrB1AxsZTl+1pru9+yaUrA4JlF1xyAVN/J/xI4Lol+23CwcRy3HfFdMsg2+HMb2x 9eKvyWpszbT5A1qjKRkp1dZRUuZbvk2c6FZ9KBOOiCKFQXAAS2D6LISm6lYFxYXQmu9H wvkoCL/yb9a6u1fW+nwJg+P98/Zd6iCkrRWp21nOWDrZt64MbpwWc4lBQad1M1+dceLB amenaRi//EOJDJnsqFuPkf/4JOeR6OM91AkxG1M67iHz5+jCgALqaLVjwYqrtfdo2DE6 DdJSU8sdZYfwrpf5bL76R9mgtrWqqDXnnpcsEooP9cuDAue9Nf8BCtQNkW5qX6QKvPYX MLiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548129; x=1703152929; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WrUatI3Cz0L0l26hy5tOUKXSSgihHrtUAipqZf1EAmE=; b=plDSBhTMuNa0E7i4MRtqWv7MnfzH4Uc4zWUrcxGreqvuiN6gw2NDNjx+AX92NMQOMe FfmhPyUvh1EQuFSpyQQRQMAVlQ78kUTzxA+ZEIrvuYflTfh8c/laqh3RbnHJarSCIRL8 7ke4Kd5ZFC8jCBFFuaOWp6h8nqLs4Z+vqLeM5hfKDSI/68LOLPBfUyS4StvHm3AMPI+E 7MhxOHXOH1OUCiJ0/Pl6WBANP644vZsgItgTptc4hIl0yX14sKSX3VAtOw/hjw6UQV38 zR2qTUOFcGOjZC+nq1Gapy4Vt/ni9gbor4OPfuyF0hUud1PpXK7nvk0k0ak1XkzUFybe YDsw== X-Gm-Message-State: AOJu0YxYVcF2EPfP7c/JuZ8AjZporfbNqc4CIc2kMlpTlvUuc6ZRdtg/ 2wvnrTYVwAC+6/pF5AJDlTdtEK2D5w== X-Google-Smtp-Source: AGHT+IExOHfYLnvhcVx/97MahYELrN89KnwOUt873aqjFXihCXT3Lm1RgNMDn1jKe1JdIwqgTZiOy41A9Q== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:534:b0:db4:6936:48b7 with SMTP id y20-20020a056902053400b00db4693648b7mr99336ybs.2.1702548129330; Thu, 14 Dec 2023 02:02:09 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:44 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-5-tabba@google.com> Subject: [PATCH v3 04/17] arm64/sysreg: Add missing system instruction definitions for FGT From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020210_596119_181C4311 X-CRM114-Status: UNSURE ( 8.49 ) 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 Add the definitions of missing system instructions that are trappable by fine grain traps. The definitions are based on DDI0602 2023-09. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/sysreg.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 9c2caf0efdc7..b320fb0de56b 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -645,6 +645,7 @@ #define OP_AT_S1E0W sys_insn(AT_Op0, 0, AT_CRn, 8, 3) #define OP_AT_S1E1RP sys_insn(AT_Op0, 0, AT_CRn, 9, 0) #define OP_AT_S1E1WP sys_insn(AT_Op0, 0, AT_CRn, 9, 1) +#define OP_AT_S1E1A sys_insn(AT_Op0, 0, AT_CRn, 9, 2) #define OP_AT_S1E2R sys_insn(AT_Op0, 4, AT_CRn, 8, 0) #define OP_AT_S1E2W sys_insn(AT_Op0, 4, AT_CRn, 8, 1) #define OP_AT_S12E1R sys_insn(AT_Op0, 4, AT_CRn, 8, 4) @@ -781,10 +782,16 @@ #define OP_TLBI_VMALLS12E1NXS sys_insn(1, 4, 9, 7, 6) /* Misc instructions */ +#define OP_GCSPUSHX sys_insn(1, 0, 7, 7, 4) +#define OP_GCSPOPCX sys_insn(1, 0, 7, 7, 5) +#define OP_GCSPOPX sys_insn(1, 0, 7, 7, 6) +#define OP_GCSPUSHM sys_insn(1, 3, 7, 7, 0) + #define OP_BRB_IALL sys_insn(1, 1, 7, 2, 4) #define OP_BRB_INJ sys_insn(1, 1, 7, 2, 5) #define OP_CFP_RCTX sys_insn(1, 3, 7, 3, 4) #define OP_DVP_RCTX sys_insn(1, 3, 7, 3, 5) +#define OP_COSP_RCTX sys_insn(1, 3, 7, 3, 6) #define OP_CPP_RCTX sys_insn(1, 3, 7, 3, 7) /* Common SCTLR_ELx flags. */ From patchwork Thu Dec 14 10:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492687 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 7B43BC4332F for ; Thu, 14 Dec 2023 10:02:54 +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:Message-ID: References:Mime-Version: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=TC0qAE2I3kPFH6CJfhTzlheqnSICUssSNLzmpFxbR70=; b=Knk7EIUNoBRGtnvQgfhDeW0twn 8M0psn3njfNC2Yf6wg8EJyBBn9Ib4134I3TiXrbCVTJXpVhuPTN7WwQL40J0XmOZ/UOcuJs1D0GzJ /TrvW38d9eD78xE/JexrlgkX0STIg+WsF7Ll/mEe18RBy63Uh1xmwjhe1ajA+JzAgJiszdqZNlrrM RGy8E12yqprBnx8tdv/BKFkRFfftkIcfpOzdqXTZ6leIujMCjHsQDke4ZbSSVLab/4QELX0uRARJO uELUEUvQVdF/o6MBsDooouLUb0uevXoGMlAh3LCB/m1DtlJJFuQXI+pWiFEqaXL4dHKD+6jrwlA5U xy2VFAOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXy-00HOwx-1I; Thu, 14 Dec 2023 10:02:26 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXl-00HOro-2r for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:15 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3334e56554bso7128550f8f.0 for ; Thu, 14 Dec 2023 02:02:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548131; x=1703152931; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=iO5cgv8s1+7lRn9EEBAbuMss8Z8UN6A/g0VvwzwiLdY=; b=N5CaZRdoklfRqZboC3TyWpylDEp9YoUVFF5RVymg1sHbtUMrsthfu4NfAIZ/PY8aqd YsTELmpO3j4NDN4ugJMzsHX1raichrLFVXs5aI3VyY9riFeb/2UOCpqfEFUREnvjl45D Iwb1w7IWsXz0kozVEiTl0l99qZB9Qmvga4tYytJkDovRyP2tNA6YA7gveZ+Cz4d8zvYa Tnm2Oz1fspPLJf8xoMmhJtximm1yxK17ckwTGoPgCfRKg2fktCWmxSkwi3KmBKG8WF66 zphlOhmwLsCKizJTnbSMXV0kSfqCfr9V7ES2PmSqxVjmoT3ugpR2MHglNXXPipEPfUek AkQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548131; x=1703152931; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iO5cgv8s1+7lRn9EEBAbuMss8Z8UN6A/g0VvwzwiLdY=; b=VWWuvYYb/sDeGQYqq2KowQPJ/5TEqE9S1+MEZWhJoBCqV/WRDgOWIvkjGnhNcut1Jr SPlQZcvIaPoRW0Rdx0C4k2OaBr2ThAEPEo2eaqRlWLirUJJvu7hAEYGAENzgwh144O7M ZvejjywporHcGScXOI8jQ+9IaTgerz6eraAlVlPVsX2bzozLbsQmOhW7BcXNFhmQRvGX cDtBcwf0gthJYi6W2tgVp//uCPlmwnZRMMglEur48vX9NWz2ceyhPQRLgzwZlP1AgL1b 3VujIHKX2Pv74p2J3D+RqxJC/gIKPJFTqtzXiiEw/jVENanoKe3BdOzcEouW89o6GIif wOlQ== X-Gm-Message-State: AOJu0YwFcE008Z9XeCNk/7j3NzdQW3dpareQ7j0YI6t7ATGc1dJzjgA6 buhHCiFcLM6Lumxs78v6OzHSyah26Q== X-Google-Smtp-Source: AGHT+IEKuhuE+8t070Z74NIEk6C7Bliycci+lz+5qRu4aMv9bjpk2q4FwL5YoB+4kB4l2qUOVyCBpGx6TQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5d:4b06:0:b0:336:4a97:9f70 with SMTP id v6-20020a5d4b06000000b003364a979f70mr1368wrq.5.1702548131670; Thu, 14 Dec 2023 02:02:11 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:45 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-6-tabba@google.com> Subject: [PATCH v3 05/17] KVM: arm64: Explicitly trap unsupported HFGxTR_EL2 features From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020213_922675_A33EE7CB X-CRM114-Status: GOOD ( 11.21 ) 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 Do not rely on the value of __HFGRTR_EL2_nMASK to trap unsupported features, since the nMASK can (and will) change as new traps are added and as its value is updated. Instead, explicitly specify the trap bits. Suggested-by: Joey Gouly Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/include/hyp/switch.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index f99d8af0b9af..7b4909dfd1f5 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -110,12 +110,15 @@ static inline void __activate_traps_hfgxtr(struct kvm_vcpu *vcpu) compute_clr_set(vcpu, HFGWTR_EL2, w_clr, w_set); } - /* The default is not to trap anything but ACCDATA_EL1 */ - r_val = __HFGRTR_EL2_nMASK & ~HFGxTR_EL2_nACCDATA_EL1; + /* The default to trap everything not handled or supported in KVM. */ + tmp = HFGxTR_EL2_nAMAIR2_EL1 | HFGxTR_EL2_nMAIR2_EL1 | HFGxTR_EL2_nS2POR_EL1 | + HFGxTR_EL2_nPOR_EL1 | HFGxTR_EL2_nPOR_EL0 | HFGxTR_EL2_nACCDATA_EL1; + + r_val = __HFGRTR_EL2_nMASK & ~tmp; r_val |= r_set; r_val &= ~r_clr; - w_val = __HFGWTR_EL2_nMASK & ~HFGxTR_EL2_nACCDATA_EL1; + w_val = __HFGWTR_EL2_nMASK & ~tmp; w_val |= w_set; w_val &= ~w_clr; From patchwork Thu Dec 14 10:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492690 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 B829EC4167B for ; Thu, 14 Dec 2023 10:02:58 +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:Message-ID: References:Mime-Version: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=rEn1Q6e9EFMRJzzozhNC1Li5lB8hYtQ1ASpkrldTEtA=; b=a/cFyr8dvRNr0K1eJDZM4l3Ms4 0FgdLY50G1xw0pks/ZAZSb6y2RvBNUYoP3t1EhigLMqd9kGbGkwaV9IK303C1745zGMyf/f/N4NXM gfFHE3U3/X0sa0BcfqtW4X+INXyV/Fn49QmIWq2APxYh4xvV35jy0YCPWaU6TULllUuhPWedNez6b su3UiDvDf2lBY7qSni/7EMT+VBeKeNBTQYlkHawXJ3G/4dRc5jxBD1AKkhB+ZTxlW6DTA8QyW6kCm X5idUzOu3DUcd1nzy8WqH2exXaAFFDOibLsXwhCx1nvE+R4gEJGDD+8VkFeg3o2tH22mTLyS+V4mu FZsItCRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXz-00HOxZ-07; Thu, 14 Dec 2023 10:02:27 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXp-00HOsq-2Q for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:19 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d42c43d8daso3226627b3.0 for ; Thu, 14 Dec 2023 02:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548134; x=1703152934; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eUvF2Iqi7HYfXyk0bPF9d7e3j/8CjJsU7OLN3xwfaaQ=; b=Nzs+YiRRZahVVV5c+bGD+BiinQJn/8eBNG1cpGzZutRVhqRXSH+715eX9n2avaiIRS sVXHNs3+kG18DAs/i3qns5KmHqgZTBNJmfb+0z8H47LsStocFY32g4PWqzspLOdhzxwK uMpRaQtj3SfAuoP4GeUqaFY4fcN07rMiMrIFsR4gJfs90wTnfxZIEkgv4WYsir/f8MH+ 11E7herx36Echzhs+QfV3U0eq0CLt1R3olFYxasu8xXi6JDlNG/INyOJP/Nm9SAqWGc1 AhKNcxOXYFCCVXCkOZtyX0d8CS7h/+6xx9U5jJ7AN+/jPno7C4449ecqH3zNC209gjJh U2ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548134; x=1703152934; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eUvF2Iqi7HYfXyk0bPF9d7e3j/8CjJsU7OLN3xwfaaQ=; b=LfxKv/b8TLozh2XccSURrEOmz/GabwuDw1rstPkJbMFy1t/NLtKl48MxB9G8YNMFM9 RtSlnU4BTyToxdNPAL5xoDJi7PuxFPRojjYVf4I5m3hlM/RKvJa1ldEiCZ+OEfbNkVal 2vb+VZB+0RJTxklijPz+1ZE5VthoXFPDsqoGY7TCZGPeKTlcGFthPK3a47er4BL3kJUf KoR0kfJZ5Kox+RqjCt630lL4GVEN3lW5xuOiBCDxWEvr0BzTCYl7jXoIqauAE9g6SU1t C/Et3vSDKSeW3PQs+3DT1DGJvKmqNHoDY6tMDd6qBJSsEWXC0QqhfbdeAD9E/XKwRQOT NKgg== X-Gm-Message-State: AOJu0YzRnicEoRbScyr58eNUKbO+fkudSyODuWJj8cvT04irXOl1rfoA OvwycHxv9/AHwmFaCnXMgg5/poN+2Q== X-Google-Smtp-Source: AGHT+IGtiqJ+ZIn5CNnbsNfDPH8yDHoyOvgqWr59kL6zpxpOMfsf2pGMh4bSAsKAtgDBenzZXZUzYblJHw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:690c:3586:b0:5d3:d44a:578d with SMTP id fr6-20020a05690c358600b005d3d44a578dmr170258ywb.4.1702548133869; Thu, 14 Dec 2023 02:02:13 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:46 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-7-tabba@google.com> Subject: [PATCH v3 06/17] KVM: arm64: Add missing HFGxTR_EL2 FGT entries to nested virt From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020217_783575_D3FA54D6 X-CRM114-Status: UNSURE ( 8.71 ) 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 Add the missing nested virt FGT table entries HFGxTR_EL2. Based on DDI0601 2023-09. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/emulate-nested.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index 06185216a297..8b473a1bbc11 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1042,10 +1042,20 @@ enum fg_filter_id { static const struct encoding_to_trap_config encoding_to_fgt[] __initconst = { /* HFGRTR_EL2, HFGWTR_EL2 */ + SR_FGT(SYS_AMAIR2_EL1, HFGxTR, nAMAIR2_EL1, 0), + SR_FGT(SYS_MAIR2_EL1, HFGxTR, nMAIR2_EL1, 0), + SR_FGT(SYS_S2POR_EL1, HFGxTR, nS2POR_EL1, 0), + SR_FGT(SYS_POR_EL1, HFGxTR, nPOR_EL1, 0), + SR_FGT(SYS_POR_EL0, HFGxTR, nPOR_EL0, 0), SR_FGT(SYS_PIR_EL1, HFGxTR, nPIR_EL1, 0), SR_FGT(SYS_PIRE0_EL1, HFGxTR, nPIRE0_EL1, 0), + SR_FGT(SYS_RCWMASK_EL1, HFGxTR, nRCWMASK_EL1, 0), SR_FGT(SYS_TPIDR2_EL0, HFGxTR, nTPIDR2_EL0, 0), SR_FGT(SYS_SMPRI_EL1, HFGxTR, nSMPRI_EL1, 0), + SR_FGT(SYS_GCSCR_EL1, HFGxTR, nGCS_EL1, 0), + SR_FGT(SYS_GCSPR_EL1, HFGxTR, nGCS_EL1, 0), + SR_FGT(SYS_GCSCRE0_EL1, HFGxTR, nGCS_EL0, 0), + SR_FGT(SYS_GCSPR_EL0, HFGxTR, nGCS_EL0, 0), SR_FGT(SYS_ACCDATA_EL1, HFGxTR, nACCDATA_EL1, 0), SR_FGT(SYS_ERXADDR_EL1, HFGxTR, ERXADDR_EL1, 1), SR_FGT(SYS_ERXPFGCDN_EL1, HFGxTR, ERXPFGCDN_EL1, 1), From patchwork Thu Dec 14 10:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492688 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 46CA9C4332F for ; Thu, 14 Dec 2023 10:02:57 +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:Message-ID: References:Mime-Version: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=DabaGhtHh5xuYjVujellb4PdFptKWdmBhRGFDhlcGow=; b=Yxccu0RjRCE99mkzGmFmXbZ+aV 3qQL/kfjIriYRBZD1cEFFrtKPG6mmujA/87E/AjPtYrJeXrPmmNWAwMYZjqV06jddGJPX4RxeNvAr WaCCHMv+bL8/Tl4FPvE+o9+9Le4PqmYlRoNt0aNP+CbXPH2uVbCBFXPcMEZaRbDxE32NcysAURS5Y UUoDWF/rwXf6GiXFUMfcE6dDkTdbnEcHlAdzF0GMZSewc4foD1yeN8kW5CYCrI/4CqkTo+HwQVHHK 8xnZcR4HZixPZ6ktZhlG0gztBknrM5ecHhNWgsA8RGx5MhlZYCqzLlcS6vjgnHxwy+RaZb3P4TIP9 PCN9hyPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXz-00HOy2-2H; Thu, 14 Dec 2023 10:02:27 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXs-00HOtK-0P for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:21 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5e03f0ede64so54956497b3.0 for ; Thu, 14 Dec 2023 02:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548136; x=1703152936; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Da8PEljTHFtyAdAg/eiKbw+wWBtYdo/VV9CYke8DnEQ=; b=06qTOoRQG5tpSnsYHw5i2Jh3i4r4KD1uq9Gois4Eme8jGUJBUQAtYnIa5wGpga3kvh ZCyWkEcZUcDwNsVEyceE0VB7Cmn1RgViqmwHS5kmBIf7CNPLREz4XlokHCX5E9hDyRIk vTkKXiCiVxX8AH/YiLWuKhNddhnZxm6qf0/MoNPicxmXhaGg70oYRuwpjTz/s9Ma5485 o/BrSTlmlYppgnqhbHbDnyU0nA50B1783u9cc9AoULwJecBg/9aNegB+m9rpxbV8tNb/ 7YKjRKP6+8hMLMQhzCetKG+UJXliAkej705hsum6UNVfarXpjifSI0C+IBVdGC/dhi5P ZPVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548136; x=1703152936; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Da8PEljTHFtyAdAg/eiKbw+wWBtYdo/VV9CYke8DnEQ=; b=JHDVH7YFSFW7JrgxoYbiTm/KW8Tc92XpFjF4tux7dnx8j5xpDGmHnODAyoABYCF2uD 1/rKyLlVdKcUHFuMEVG+3sX2rFTvHnwwJSjUViadqN7ga4u78xuju76qKGEHi9Zsux4r LxlwEhLAK4+Z1RDrGU+MaVx84jv+tFITBtsSNRozQx6JcHypyFaJM8zyBiMSjUamwwI3 oRqtIiUcm2jDg566nJ6yQ0Sn7qyCqwQZN01vph/DI3lxRmjmg5KQtnb9iHykQcl9KtNs rMJ+LvHD574PvOXyXX+EuFsprVoStObEVVOXqCLNvORXgqJCvnkO6e6DT7zvtDcWBS6u Ggfg== X-Gm-Message-State: AOJu0YxxkvQ7QrFYOMcCDV1mHvIj4rFWN3M1lG9kLvlnNuXH/OMYp0nC yvzBEP+S4Rv6JN5XuRCWOoaHZ3+YTQ== X-Google-Smtp-Source: AGHT+IEuw+3Pg+LXmSjMTI015X5o2FNJIMfMU9lFQxidELjvY70BfLIQKtuu/0eWkY2P/YRS+CobhfzYvw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:185:b0:dbc:c7f0:7c2e with SMTP id t5-20020a056902018500b00dbcc7f07c2emr50863ybh.2.1702548136159; Thu, 14 Dec 2023 02:02:16 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:47 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-8-tabba@google.com> Subject: [PATCH v3 07/17] KVM: arm64: Add missing HFGITR_EL2 FGT entries to nested virt From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020220_168676_D8565652 X-CRM114-Status: UNSURE ( 8.93 ) 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 Add the missing nested virt FGT table entries HFGITR_EL2. Based on DDI0601 and DDI0602 2023-09. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/emulate-nested.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index 8b473a1bbc11..89901550db34 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1117,6 +1117,11 @@ static const struct encoding_to_trap_config encoding_to_fgt[] __initconst = { SR_FGT(SYS_AFSR1_EL1, HFGxTR, AFSR1_EL1, 1), SR_FGT(SYS_AFSR0_EL1, HFGxTR, AFSR0_EL1, 1), /* HFGITR_EL2 */ + SR_FGT(OP_AT_S1E1A, HFGITR, ATS1E1A, 1), + SR_FGT(OP_COSP_RCTX, HFGITR, COSPRCTX, 1), + SR_FGT(OP_GCSPUSHX, HFGITR, nGCSEPP, 0), + SR_FGT(OP_GCSPOPX, HFGITR, nGCSEPP, 0), + SR_FGT(OP_GCSPUSHM, HFGITR, nGCSPUSHM_EL1, 0), SR_FGT(OP_BRB_IALL, HFGITR, nBRBIALL, 0), SR_FGT(OP_BRB_INJ, HFGITR, nBRBINJ, 0), SR_FGT(SYS_DC_CVAC, HFGITR, DCCVAC, 1), From patchwork Thu Dec 14 10:01:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492692 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 7B28FC4167D for ; Thu, 14 Dec 2023 10:03:00 +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:Message-ID: References:Mime-Version: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=RcO722A9bwiL/5ozlQI+w75gL5KwHgzmiXRAHYgiHcA=; b=2LvypWzbKV4eNRrB3cY4o4ITTs wMQ80HteUKGcMagzgqimmPUtjdLxCoXYboDyXK6rqso0Y1KsZQ4X7Htuf9b0PQPglaHIrfVZPSIqs udhvz0bIfrimU3cOWsvgnzwa+gKT7E3zQFhuHDTGdEB6B/jcIrVIope9OiLoS3/SO2Q2jO6wJalZq 6ZsQI+M1fKVzCVDwQo6PiJy4MF5j1h/h75yIBLNLrGYM6QakxrT8LJpRD8LBOSsLrqexshCzkbHWf gY3ifRUGc3ViS+WvAn4pwkAJjULSRgqA+XyM77vzimIUwYH0Vhb58QTN+ToqIhMXbtRcKeSgtf+mL xwf4MMXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiY0-00HOyg-1L; Thu, 14 Dec 2023 10:02:28 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXs-00HOts-1M for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:21 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-33340d20b90so6616498f8f.2 for ; Thu, 14 Dec 2023 02:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548138; x=1703152938; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hWCr/u0/LEl0Qz/K61SKmSilcDBET0Mpt8ezhmPfdL0=; b=WXyC3F6KPs3knXZaEa++MAatqIkUVrLlttzJWqMh1qbCNOtxnh5gmSnAfdudKsspAg 3GOAbceBGE2w+XD23ZvDEcTvGHs9TdZyKMiAov6gkpeJlFipa2BVmrXzYenz5cz+zTsF jc3bL3oC7hvZQRkvRh4Ff2PrtRe78KfA78wXEC0Zv+pwONlIy+gxjcPinJCLDJMxmmQj cOd5UygvA+s1+deDs0k9iFNbi9GHVMXQAUx1P5AUnQvgmlYtd1sIu6k4QFhZ7OUp1hnM uywFHboQNWGiUDJyTkO9+LVwoKwpJ/SIY6wyh+DHlvXqL5hkxzvwCukWlwaVrV/iHo7t ymgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548138; x=1703152938; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hWCr/u0/LEl0Qz/K61SKmSilcDBET0Mpt8ezhmPfdL0=; b=tkppTM/y3oIhbXdo13v8qC2WzhlCVZgMe/+bnEbQFwIb33Ya7Mnz1H9hql2GRhg/zE 4XlwgS1WXjM9SZKgGpcfM6R7yFc7r4n6Rcb49eUI7BlHG9gUoFStCsTEti8dvvKNdSty Vcwy7vvX+x+0l/UTo4PrjU6utqvbOc/DDSy/41P7rWvo2NfZmE+ch7mNdpbWRDbL7/3A albJeCHjiAaCBUILERqaDWCKS8wWqRPJHZHS08jYzB+5/UDck7KrfexsU8rTtTdFuww7 j7eZzO1fZMSbBb5xivauTCzCi56uIpAvSuDJDrP1j2ob7rQKhHnWWGaP2NCEVoZ0IVrA bzKw== X-Gm-Message-State: AOJu0Yz8oQ3nG51U17pK/PxU9Uz0GP81sWc5QbCL4ktS4Bah3dHuO2Px Oy7QPiBji03OqO9V5nJEHih/KP2b0Q== X-Google-Smtp-Source: AGHT+IFL2ThU73Trz4Wy9pYB2yLh/2X8/PtTAtN1qdC64iHsHskqYdTX9A2+HSCsuauP2OUpLSO2Us+QPg== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6000:4024:b0:333:43b5:ef39 with SMTP id cp36-20020a056000402400b0033343b5ef39mr50416wrb.10.1702548138483; Thu, 14 Dec 2023 02:02:18 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:48 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-9-tabba@google.com> Subject: [PATCH v3 08/17] KVM: arm64: Add bit masks for HAFGRTR_EL2 From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020220_460562_4CA6231C X-CRM114-Status: UNSURE ( 9.23 ) 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 To support HAFGRTR_EL2 supported in nested virt in the following patch, first add its bitmask definitions based on DDI0601 2023-09. Reviewed-by: Mark Brown Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_arm.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index b85f46a73e21..7de0a7062625 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -370,6 +370,10 @@ #define __HDFGWTR_EL2_MASK ~__HDFGWTR_EL2_nMASK #define __HDFGWTR_EL2_nMASK GENMASK(62, 60) +#define __HAFGRTR_EL2_RES0 (GENMASK(63, 50) | GENMASK(16, 5)) +#define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0)) +#define __HAFGRTR_EL2_nMASK 0UL + /* Similar definitions for HCRX_EL2 */ #define __HCRX_EL2_RES0 (GENMASK(63, 16) | GENMASK(13, 12)) #define __HCRX_EL2_MASK (0) From patchwork Thu Dec 14 10:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492689 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 19582C4167D for ; Thu, 14 Dec 2023 10:02:58 +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:Message-ID: References:Mime-Version: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=z7uKZxNxGFIKTFbGZaE8nnJzc/Yfy8Yp8DXO8PtjfDo=; b=JbdXdxUCbukXeifN1Qj9q8pm8t Hqx48EB04zXw4eUyCkzxDUd5cnKncV34CKeAMsnkbrY66b91u8UXE0p5geUvo7j9VogVy8DtioHpu N6dZ9jyhAVrwOaNbnUw/wqadArm3cFFUhGoXQQ/d2AdcYBhBLEwxy6LIhun4VbIB1mFuwBPNsZ1l7 jB4XEQz4kJaIayZ73yOEAFOVR5wemrLDm1u5jdaE522UDMyRC4ZNtEOd7i4OX1zfARFpUzLvzy1r7 9Lc7lc//TT6K8qlLVo2K8qNWDMuqABO9hEskGa5qI5gsKUAX1mZ97OXLgkbtRtHaL8Hc7UytB1ASt dWOyd3fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiY1-00HOzN-1S; Thu, 14 Dec 2023 10:02:29 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXu-00HOup-0C for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:23 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5e1ee53972dso33995387b3.1 for ; Thu, 14 Dec 2023 02:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548141; x=1703152941; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LWwzLbvByHCmWMHsPOp6gqtuDic+laOykV5wdqH7WEA=; b=MAFshDOD4c8hWrTpKFqlhroC+GhWJlOBM5lwjOphgPwUKxpdKM+udu7ZpLhB36+cp6 e2rKaRjkZv6W4CkrZsJKKaVqApnIpryUWK0tPTKnVsfA7mXbhRDKrxZjJLxVV+uGafS2 xWiJOmgFALMdsDtr2mcNWfaDAam5kEE0R4ETO5bKbkILfcysTYr4PTUvkY/3UXwJPkg1 7Fctf8kneUl0ImcY65JADpNNL3YT4BCpeHV8lbTq1xQbadXm6/s9pIBPIJbNYeXcBpvX w6ZlxrHb9j2oYjS5tProQ3xTK+W7MZrTc0B8OlnucZFpy7CDzAPwvXMSmMeGtH/QdjHt p4sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548141; x=1703152941; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LWwzLbvByHCmWMHsPOp6gqtuDic+laOykV5wdqH7WEA=; b=MkE9CYqr15SnoZ63qrLaVPhWJboWLS4LQ6q7fiVECfer4a+X6BrMdQX1zcYmARk3HQ afo+osRsMDruhWRQfeEQPLJxC/7+4DZnAaxB+aOAVCQUL5WxAOs2DMWFQTV2DZ0GabO3 WV7Z14IA7NPguU7OXe6qx5vRabj59A2aDebETe7vk6KbMB5+oQvwckTeAHn55Tbd+VMp p6s34HMnqSPc0fqeWCaWBJEwLquwIgxja7RqO++W90Nxl5hkKa4nwZ1BDUbZcQ+mWEwO A56PAHfGIWY6cHoINvz+NA5+NIcobAajnV/cqABYX8szGL7EJl2QMQH8q3zpYwDzWtMa CulQ== X-Gm-Message-State: AOJu0Yyizu6gxTaoLsD9hlLWu+gyo8EhfAkZr5ANmhZlOnfPq57a/9uZ d2Ivw1ChiMf0G1gus3rAQnocJQ4QIg== X-Google-Smtp-Source: AGHT+IEQz3VBSiDveYMYZZJRvCqTfLzVPzfPWPwNQqScEnd95XhL1OToVJz/PKu0HJcWp0GJCwuKytlQyA== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:4e5:b0:dbc:cf1a:312c with SMTP id w5-20020a05690204e500b00dbccf1a312cmr36793ybs.4.1702548140735; Thu, 14 Dec 2023 02:02:20 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:49 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-10-tabba@google.com> Subject: [PATCH v3 09/17] KVM: arm64: Handle HAFGRTR_EL2 trapping in nested virt From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020222_100215_A4B5F07E X-CRM114-Status: GOOD ( 12.41 ) 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 Add the encodings to fine grain trapping fields for HAFGRTR_EL2 and add the associated handling code in nested virt. Based on DDI0601 2023-09. Add the missing field definitions as well, both to generate the correct RES0 mask and to be able to toggle their FGT bits. Also add the code for handling FGT trapping, reading of the register, to nested virt. Reviewed-by: Mark Brown Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/emulate-nested.c | 48 +++++++++++++++++++++++++ arch/arm64/kvm/hyp/include/hyp/switch.h | 12 +++++++ arch/arm64/kvm/sys_regs.c | 1 + 4 files changed, 62 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 824f29f04916..ba14648e2de2 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -443,6 +443,7 @@ enum vcpu_sysreg { HFGITR_EL2, HDFGRTR_EL2, HDFGWTR_EL2, + HAFGRTR_EL2, CNTHP_CTL_EL2, CNTHP_CVAL_EL2, CNTHV_CTL_EL2, diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index 89901550db34..431fd429932d 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1012,6 +1012,7 @@ enum fgt_group_id { HDFGRTR_GROUP, HDFGWTR_GROUP, HFGITR_GROUP, + HAFGRTR_GROUP, /* Must be last */ __NR_FGT_GROUP_IDS__ @@ -1689,6 +1690,49 @@ static const struct encoding_to_trap_config encoding_to_fgt[] __initconst = { SR_FGT(SYS_PMCR_EL0, HDFGWTR, PMCR_EL0, 1), SR_FGT(SYS_PMSWINC_EL0, HDFGWTR, PMSWINC_EL0, 1), SR_FGT(SYS_OSLAR_EL1, HDFGWTR, OSLAR_EL1, 1), + /* + * HAFGRTR_EL2 + */ + SR_FGT(SYS_AMEVTYPER1_EL0(15), HAFGRTR, AMEVTYPER115_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(14), HAFGRTR, AMEVTYPER114_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(13), HAFGRTR, AMEVTYPER113_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(12), HAFGRTR, AMEVTYPER112_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(11), HAFGRTR, AMEVTYPER111_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(10), HAFGRTR, AMEVTYPER110_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(9), HAFGRTR, AMEVTYPER19_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(8), HAFGRTR, AMEVTYPER18_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(7), HAFGRTR, AMEVTYPER17_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(6), HAFGRTR, AMEVTYPER16_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(5), HAFGRTR, AMEVTYPER15_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(4), HAFGRTR, AMEVTYPER14_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(3), HAFGRTR, AMEVTYPER13_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(2), HAFGRTR, AMEVTYPER12_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(1), HAFGRTR, AMEVTYPER11_EL0, 1), + SR_FGT(SYS_AMEVTYPER1_EL0(0), HAFGRTR, AMEVTYPER10_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(15), HAFGRTR, AMEVCNTR115_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(14), HAFGRTR, AMEVCNTR114_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(13), HAFGRTR, AMEVCNTR113_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(12), HAFGRTR, AMEVCNTR112_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(11), HAFGRTR, AMEVCNTR111_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(10), HAFGRTR, AMEVCNTR110_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(9), HAFGRTR, AMEVCNTR19_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(8), HAFGRTR, AMEVCNTR18_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(7), HAFGRTR, AMEVCNTR17_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(6), HAFGRTR, AMEVCNTR16_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(5), HAFGRTR, AMEVCNTR15_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(4), HAFGRTR, AMEVCNTR14_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(3), HAFGRTR, AMEVCNTR13_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(2), HAFGRTR, AMEVCNTR12_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(1), HAFGRTR, AMEVCNTR11_EL0, 1), + SR_FGT(SYS_AMEVCNTR1_EL0(0), HAFGRTR, AMEVCNTR10_EL0, 1), + SR_FGT(SYS_AMCNTENCLR1_EL0, HAFGRTR, AMCNTEN1, 1), + SR_FGT(SYS_AMCNTENSET1_EL0, HAFGRTR, AMCNTEN1, 1), + SR_FGT(SYS_AMCNTENCLR0_EL0, HAFGRTR, AMCNTEN0, 1), + SR_FGT(SYS_AMCNTENSET0_EL0, HAFGRTR, AMCNTEN0, 1), + SR_FGT(SYS_AMEVCNTR0_EL0(3), HAFGRTR, AMEVCNTR03_EL0, 1), + SR_FGT(SYS_AMEVCNTR0_EL0(2), HAFGRTR, AMEVCNTR02_EL0, 1), + SR_FGT(SYS_AMEVCNTR0_EL0(1), HAFGRTR, AMEVCNTR01_EL0, 1), + SR_FGT(SYS_AMEVCNTR0_EL0(0), HAFGRTR, AMEVCNTR00_EL0, 1), }; static union trap_config get_trap_config(u32 sysreg) @@ -1909,6 +1953,10 @@ bool __check_nv_sr_forward(struct kvm_vcpu *vcpu) val = sanitised_sys_reg(vcpu, HDFGWTR_EL2); break; + case HAFGRTR_GROUP: + val = sanitised_sys_reg(vcpu, HAFGRTR_EL2); + break; + case HFGITR_GROUP: val = sanitised_sys_reg(vcpu, HFGITR_EL2); switch (tc.fgf) { diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 7b4909dfd1f5..22f3b916f60c 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -156,6 +156,17 @@ static inline void __activate_traps_hfgxtr(struct kvm_vcpu *vcpu) write_sysreg_s(r_val, SYS_HDFGRTR_EL2); write_sysreg_s(w_val, SYS_HDFGWTR_EL2); + + ctxt_sys_reg(hctxt, HAFGRTR_EL2) = read_sysreg_s(SYS_HAFGRTR_EL2); + + r_clr = r_set = 0; + compute_clr_set(vcpu, HAFGRTR_EL2, r_clr, r_set); + + r_val = __HAFGRTR_EL2_nMASK; + r_val |= r_set; + r_val &= ~r_clr; + + write_sysreg_s(r_val, SYS_HAFGRTR_EL2); } static inline void __deactivate_traps_hfgxtr(struct kvm_vcpu *vcpu) @@ -174,6 +185,7 @@ static inline void __deactivate_traps_hfgxtr(struct kvm_vcpu *vcpu) write_sysreg_s(ctxt_sys_reg(hctxt, HFGITR_EL2), SYS_HFGITR_EL2); write_sysreg_s(ctxt_sys_reg(hctxt, HDFGRTR_EL2), SYS_HDFGRTR_EL2); write_sysreg_s(ctxt_sys_reg(hctxt, HDFGWTR_EL2), SYS_HDFGWTR_EL2); + write_sysreg_s(ctxt_sys_reg(hctxt, HAFGRTR_EL2), SYS_HAFGRTR_EL2); } static inline void __activate_traps_common(struct kvm_vcpu *vcpu) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 4735e1b37fb3..8bb297a2df38 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2532,6 +2532,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_DACR32_EL2), trap_undef, reset_unknown, DACR32_EL2 }, EL2_REG(HDFGRTR_EL2, access_rw, reset_val, 0), EL2_REG(HDFGWTR_EL2, access_rw, reset_val, 0), + EL2_REG(HAFGRTR_EL2, access_rw, reset_val, 0), EL2_REG(SPSR_EL2, access_rw, reset_val, 0), EL2_REG(ELR_EL2, access_rw, reset_val, 0), { SYS_DESC(SYS_SP_EL1), access_sp_el1}, From patchwork Thu Dec 14 10:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492694 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 40E35C4332F for ; Thu, 14 Dec 2023 10:03:21 +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:Message-ID: References:Mime-Version: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=Rgd5VtbI9JcJkkSBl7A5ERqfEYE6rsXtXIMcA7bEbkk=; b=xKQqSE+pwW6CozeywM6PSkJ9yO M09oJwLb5z0jyd+ei7KBhD+f0rooXgWANrGEYOWd6SW9T/w0GKvdDUUm/82uPIzIJOu4eF8gJnLY9 wiLeGez4aXWgaGirADS4W9Ggkrej9EbEd7UtyuN43L42bntD+qsbAdUggQOHBcnIrj8xyGQ5abhD9 EzZghuLh58xipXuyFqPJ/aY+srS0yGzbr9ynq3kOkRw8PDScLS1RuqdvSaGP94TWw31j4sx2ojvAR 6NZq+dl5leaDt0Y564Ti7S22FH6NY6v5qDgUpZyA7mooVTLXtkribs2cG9Oi0doV6w+j4oJcuDnij sHM5fo6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiYQ-00HPGQ-22; Thu, 14 Dec 2023 10:02:54 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXw-00HOvd-1J for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:25 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5e2f0e7e17dso17040417b3.3 for ; Thu, 14 Dec 2023 02:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548143; x=1703152943; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=i5gQXx09qcREZzryPULHtbRcGtK2VgeJB/Kj9vzazEw=; b=aHMFg9MEQvU4/uKO4VHFvtOyhAy+b/jWvi38wg3Je8RdGCHNaeEg+oEwRDHPABpZGN vY7zG5Qgrzj3/BE0iDBO+6Jy4n3wQldQ5O2HLsru6gI/UKc+2GF4Yz+pb8bci0C/gqrl Nc6e20RhWldQuHsPVJy9bAp31CVI0KA5TEFR6PAHz7YDsttMfiPzwFtp3gDYJFcK2Qeu S5UoyhoeGUnPqfca4xKDFT18ZWLrp6PofCNcQVm2ynqPTY4IP6lMQOKxa+DXFWn4BCfJ vYZ/6c5rlOs6wx1LYxb2zIwdqTg1eUS2+8QK243SikK+kVRyo+hdscYc5gTFwyygIWDU VHnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548143; x=1703152943; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i5gQXx09qcREZzryPULHtbRcGtK2VgeJB/Kj9vzazEw=; b=J4Ep45t1oKkreGKhuwduPS5STlW4WCbUoYOO7pyhGKAWkyl80pxg3D+MBKDqWB4Skn IcyR57tRudzV5Ae48Fbf8hshzp0N1HKSl/YAybx8H9xK4YTeUdjo2c++NXp19bjBq1V4 A+uOQEA3tmJiJOHc9I9aMkNq4kwtTHB44T6le1pVnQlDKKKRxRKymAyzDrPf3yP+p/WY Xarc8XOM190OtQGPdQrHRkEQVbUn66TGKe3xYmiYT3imicFlAbi3Lq50no6DApriNkZs R/htYjSITZML6+g3XJ+FZAgI95EusYW2XWB93FOuRovQWcIIn+lFTnFgqwMSozWOvoo6 CjMQ== X-Gm-Message-State: AOJu0YxyUF+cncKwFdyB+vFPqVNJBUp4VzfiitgmCBPs+y0jyV0DbeSo klH51fawe6kAJ/+wFgUa4HDLTI/AQg== X-Google-Smtp-Source: AGHT+IGsVKQuOdWWEcKxeUozb/6rs0MXEj2XWfE6tghHpcrfAfgFpTD/eWCv6Y+3GCtQprtF3oD5mK159g== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:690c:3747:b0:5d5:5183:ebd7 with SMTP id fw7-20020a05690c374700b005d55183ebd7mr104796ywb.7.1702548142956; Thu, 14 Dec 2023 02:02:22 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:50 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-11-tabba@google.com> Subject: [PATCH v3 10/17] KVM: arm64: Update and fix FGT register masks From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020224_448389_B845F95C X-CRM114-Status: GOOD ( 13.09 ) 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 New trap bits have been defined since the latest update to this patch. Moreover, the existing definitions of some of the mask and the RES0 bits overlap, which could be wrong, confusing, or both. Update the bits based on DDI0601 2023-09, and ensure that the existing bits are consistent. Subsequent patches will use the generated RES0 fields instead of specifying them manually. This patch keeps the manual encoding of the bits to make it easier to review the series. Fixes: 0fd76865006d ("KVM: arm64: Add nPIR{E0}_EL1 to HFG traps") Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_arm.h | 39 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 7de0a7062625..b0dc3249d5cd 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -344,30 +344,39 @@ * Once we get to a point where the two describe the same thing, we'll * merge the definitions. One day. */ -#define __HFGRTR_EL2_RES0 (GENMASK(63, 56) | GENMASK(53, 51)) +#define __HFGRTR_EL2_RES0 BIT(51) #define __HFGRTR_EL2_MASK GENMASK(49, 0) -#define __HFGRTR_EL2_nMASK (GENMASK(58, 57) | GENMASK(55, 54) | BIT(50)) +#define __HFGRTR_EL2_nMASK (GENMASK(63, 52) | BIT(50)) -#define __HFGWTR_EL2_RES0 (GENMASK(63, 56) | GENMASK(53, 51) | \ - BIT(46) | BIT(42) | BIT(40) | BIT(28) | \ - GENMASK(26, 25) | BIT(21) | BIT(18) | \ +#define __HFGWTR_EL2_RES0 (BIT(51) | BIT(46) | BIT(42) | BIT(40) | \ + BIT(28) | GENMASK(26, 25) | BIT(21) | BIT(18) | \ GENMASK(15, 14) | GENMASK(10, 9) | BIT(2)) -#define __HFGWTR_EL2_MASK GENMASK(49, 0) -#define __HFGWTR_EL2_nMASK (GENMASK(58, 57) | GENMASK(55, 54) | BIT(50)) +#define __HFGWTR_EL2_MASK (GENMASK(49, 47) | GENMASK(45, 43) | \ + BIT(41) | GENMASK(39, 29) | BIT(27) | \ + GENMASK(24, 22) | GENMASK(20, 19) | \ + GENMASK(17, 16) | GENMASK(13, 11) | \ + GENMASK(8, 3) | GENMASK(1, 0)) +#define __HFGWTR_EL2_nMASK (GENMASK(63, 52) | BIT(50)) -#define __HFGITR_EL2_RES0 GENMASK(63, 57) -#define __HFGITR_EL2_MASK GENMASK(54, 0) -#define __HFGITR_EL2_nMASK GENMASK(56, 55) +#define __HFGITR_EL2_RES0 (BIT(63) | BIT(61)) +#define __HFGITR_EL2_MASK (BIT(62) | BIT(60) | GENMASK(54, 0)) +#define __HFGITR_EL2_nMASK GENMASK(59, 55) #define __HDFGRTR_EL2_RES0 (BIT(49) | BIT(42) | GENMASK(39, 38) | \ GENMASK(21, 20) | BIT(8)) -#define __HDFGRTR_EL2_MASK ~__HDFGRTR_EL2_nMASK +#define __HDFGRTR_EL2_MASK (BIT(63) | GENMASK(58, 50) | GENMASK(48, 43) | \ + GENMASK(41, 40) | GENMASK(37, 22) | \ + GENMASK(19, 9) | GENMASK(7, 0)) #define __HDFGRTR_EL2_nMASK GENMASK(62, 59) #define __HDFGWTR_EL2_RES0 (BIT(63) | GENMASK(59, 58) | BIT(51) | BIT(47) | \ BIT(43) | GENMASK(40, 38) | BIT(34) | BIT(30) | \ BIT(22) | BIT(9) | BIT(6)) -#define __HDFGWTR_EL2_MASK ~__HDFGWTR_EL2_nMASK +#define __HDFGWTR_EL2_MASK (GENMASK(57, 52) | GENMASK(50, 48) | \ + GENMASK(46, 44) | GENMASK(42, 41) | \ + GENMASK(37, 35) | GENMASK(33, 31) | \ + GENMASK(29, 23) | GENMASK(21, 10) | \ + GENMASK(8, 7) | GENMASK(5, 0)) #define __HDFGWTR_EL2_nMASK GENMASK(62, 60) #define __HAFGRTR_EL2_RES0 (GENMASK(63, 50) | GENMASK(16, 5)) @@ -375,9 +384,9 @@ #define __HAFGRTR_EL2_nMASK 0UL /* Similar definitions for HCRX_EL2 */ -#define __HCRX_EL2_RES0 (GENMASK(63, 16) | GENMASK(13, 12)) -#define __HCRX_EL2_MASK (0) -#define __HCRX_EL2_nMASK (GENMASK(15, 14) | GENMASK(4, 0)) +#define __HCRX_EL2_RES0 (GENMASK(63, 25) | GENMASK(13, 12)) +#define __HCRX_EL2_MASK (BIT(6)) +#define __HCRX_EL2_nMASK (GENMASK(24, 14) | GENMASK(11, 7) | GENMASK(5, 0)) /* Hyp Prefetch Fault Address Register (HPFAR/HDFAR) */ #define HPFAR_MASK (~UL(0xf)) From patchwork Thu Dec 14 10:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492695 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 E1F19C4332F for ; Thu, 14 Dec 2023 10:03: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:Message-ID: References:Mime-Version: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=2tKe4JIs5Bg33SB6LYtAQSKF9Jh6JJtecJ7KA3uiwPI=; b=gi4BqkrkDYNioRK2324pOic4cu 3aWIL+y77Lkk3dMNw3FF26PlHUG5AL0ILm/QFUbco45h/t9bhdfMN3mJSrMoIJUGL4Ybk/LLRPZB/ LJksRHQHr1lGUhlhCBSOOYYLM8UoLwfuVGlZTftwOdqfII2JSpVyNLIormYFY0314hyCGvzAN647O w1admU7jQEDzbRtJNLFLAdLyOsDPMC2BJFVVamGgw1zE+R+GkiAqHWwavKaWJkp3EhO1VMjFbRz4h xDb7+Yf/1B2/8CCp0NQBKexqezyAofiX6nWYmyL5/o7m/3y/ErAWmjiMtfS/3Nh8MwZiUd+z9ZfiT u9n/c7xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDiYR-00HPH8-1z; Thu, 14 Dec 2023 10:02:55 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiXy-00HOwS-1T for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:27 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d0c4ba7081so94682417b3.0 for ; Thu, 14 Dec 2023 02:02:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548145; x=1703152945; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=MtoBQdO9BZcT6cVULOx3THPVjJf72EU09T5C8iMtUIE=; b=IoWZZEv5t05KTJpW2G68w/0QudQdSoDJLVzi26uqYfUDjKYaGEZXoTs9Thka1U4IXO 05ZYsK4xTLWaaFNeqGLBpyjrOYpcejkslL1j1WVeOZQCbajkh/MpAN5mIGg1GDlHEoq2 RFsZepXty467al5Bt06wfyFcswRHhhHxzglQLZ28EJ5ZJgxYNVWVJnbkHtLktjnVoNbP xc8/701AP7XMLFwStj1LPoy/lYxl3ulGvwOsNt23flgHjQpQzX5egxjypuHFb8exLfxe 4+/w+mSDT3vTLa4O37940f4iqDGAVsAykSlW0jaO1THTAR3iJWIUifIfOJ5VK/B+t+CG ioWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548145; x=1703152945; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MtoBQdO9BZcT6cVULOx3THPVjJf72EU09T5C8iMtUIE=; b=uDZxK3fkfi/Dpy+sLD3cb9gz4MHLJdAvSGlRkS1RyG4bWcEakhy/FHWpjkbE+N1FTN ntLG/O1cCEGRuuELw6hy36G2BbZUlLB28GfSqTHLZvcycjOWjQeohfN1lcexuXc7Z/SH y0UAt8FuO+FsQbrXB6O72TYeSTO/hcZtJEuAYuYjCON/V5o5i5FZ/ITOQgGnh9GbPQuD Y8X0lNUWQ6387gMnSBLZ5uBRl+LbQthvQCF4Q0am52XjVP/H+sriNFHn4KU4wGtV1HTc w/ONktN/kDv3DJjd34lGtiIr1Lt4RhiqkQzpvxv1argJ84yyLZHKVR2ltzOZ9u3syAiC pi+A== X-Gm-Message-State: AOJu0YxHWJNn1CfTvUNJuXefR4xZ8DoLTlML7gUyaCoriPCgh3HlpOCz PYYf516dLumvgIoGuEpMqU8IFzaMkg== X-Google-Smtp-Source: AGHT+IF3yQ4ifUSZxuey84w9AQVk0MTmWSACizMj1HStOjIjCJwuTOu76xneTkqOBFoVyWUvXJZXskiKxQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:690c:891:b0:5d0:a744:719a with SMTP id cd17-20020a05690c089100b005d0a744719amr115733ywb.2.1702548145070; Thu, 14 Dec 2023 02:02:25 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:51 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-12-tabba@google.com> Subject: [PATCH v3 11/17] KVM: arm64: Add build validation for FGT trap mask values From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020226_491701_E4E7DC37 X-CRM114-Status: GOOD ( 10.41 ) 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 These checks help ensure that all the bits are accounted for, that there hasn't been a transcribing error from the spec nor from the generated mask values, which will be used in subsequent patches. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/include/hyp/switch.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 22f3b916f60c..17ce40f5b006 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -79,6 +79,16 @@ static inline void __activate_traps_fpsimd32(struct kvm_vcpu *vcpu) clr |= ~hfg & __ ## reg ## _nMASK; \ } while(0) +/* + * Validate the fine grain trap masks. + * Check that the masks do not overlap and that all bits are accounted for. + */ +#define CHECK_FGT_MASKS(reg) \ + do { \ + BUILD_BUG_ON((__ ## reg ## _MASK) & (__ ## reg ## _nMASK)); \ + BUILD_BUG_ON(~((__ ## reg ## _RES0) ^ (__ ## reg ## _MASK) ^ \ + (__ ## reg ## _nMASK))); \ + } while(0) static inline void __activate_traps_hfgxtr(struct kvm_vcpu *vcpu) { @@ -86,6 +96,14 @@ static inline void __activate_traps_hfgxtr(struct kvm_vcpu *vcpu) u64 r_clr = 0, w_clr = 0, r_set = 0, w_set = 0, tmp; u64 r_val, w_val; + CHECK_FGT_MASKS(HFGRTR_EL2); + CHECK_FGT_MASKS(HFGWTR_EL2); + CHECK_FGT_MASKS(HFGITR_EL2); + CHECK_FGT_MASKS(HDFGRTR_EL2); + CHECK_FGT_MASKS(HDFGWTR_EL2); + CHECK_FGT_MASKS(HAFGRTR_EL2); + CHECK_FGT_MASKS(HCRX_EL2); + if (!cpus_have_final_cap(ARM64_HAS_FGT)) return; From patchwork Thu Dec 14 10:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492819 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 9480BC4332F for ; Thu, 14 Dec 2023 11:17:05 +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:Message-ID: References:Mime-Version: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=fDVYo74u0guOtTk3bCZCpo+qIo1k/F4zwxz67xfAueA=; b=JPBJG17ONynqTVsBYYPsnqXR5W 5g53hdXqIltJ9GlUp4WJjwyafkxQyFklxMsZjnkZC1wVv0tZuc7awieyt121RrV7JrapFy7wrF7Er Iu78NgzXZ1QqjZSuJHOk6cWuq1WeWPBqrg/rlqGu5GZ4IL/zmjzwtxlG6uL+BxU+ZruIevgvXe5Va l5fwYOXqWr3aYt/3DIYRWSP7pgegh9to59PCOcmCWl5lPkVV0pCm8GOBzWQEhDJClHg9034IkXrS3 FkVlZVtSiTjlx2xKwegq37Sop4w3lpaO/AdmNOvJM+8VNnkGkLfO3bqXo8VFfAmhis4CVu6skz9f8 i/I60YWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjhk-0000P0-1s; Thu, 14 Dec 2023 11:16:36 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiY1-00HOy7-1a for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:31 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3334b1055fbso6588436f8f.2 for ; Thu, 14 Dec 2023 02:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548147; x=1703152947; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2YHMfz93osdDIzHj8sFYcObKkkgc+A/MWXsB9b6JOSI=; b=OB6RtROfjGh+epqwDn2pAdy3TWmgwrSuZMMGiVuy1v/wPQKjLhKWkwJUS2TXyn2z3E fjE9LrnPcXrBdgLbAzO1RvXChxeB7KUbMF6a1ug9RzxVLuioT9Qb6IvHRHMFaXGN56Ax DYOBJWEMdq52RKyDtzkAkxRz/iEK4uWZIfq3npzC/IQxWYQQjTpdBUR3RX6MVRwkSvHo ggOiTeMXhNgYlP5QFv1szlgaLQo5504YYf2PUFdNfean4o/fSc6Q0rfVMjFX3t7175wM Ju5YhSTCh2bjHIylejCDqawWPbC1cxLLtQFd0WPCk5zgsWvX82wcVHFpEzCo1jR+skmJ nnog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548147; x=1703152947; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2YHMfz93osdDIzHj8sFYcObKkkgc+A/MWXsB9b6JOSI=; b=wuWK7EYVGuTVC7yZnOV050IOsNVob5t2TpRxrROZI9mrhQJenpwSKoyPDDrWvImtcj p82cm3c9Rmoyjc3pU6yxiOruOdKX2D3BU6npj+uJB6li6SB/z8P/txJiQhDtUmkWwkCr aDES9i13dgtS9OYJmNYkB8W/gv+6qy7aG/0g9uVZwrxCFqEgFVatHHcypdO8ItA4F0n3 aKYYvrFp49PlBSX0jBLuU1QfrW3jOWq3SEg3BEvlOTnQq5D5vr8YSCq0GmjtDfR9XKyj bmiByYtdPtlQhN/AixDUeJRUIWb7k14e7RaSaYpIfqpa7Oi6Qnlk/h7oP7Cy5QwFZOv7 W+pA== X-Gm-Message-State: AOJu0YzihYGyh9Xfe8YkGUfjH4zbWB8QhJStOKKT32tYxAJYBMJCjYw8 jCjOPsqacs/q0YsYqzJvAvJEuazL8Q== X-Google-Smtp-Source: AGHT+IGYJ2r+eNVdRL3O6QiEgHCH0b4HeQUoNWeRagEwAx1cqIKSOHfeyUAxUn78URaYgFjOR7hmR2d2KQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5d:64ca:0:b0:333:3363:2e19 with SMTP id f10-20020a5d64ca000000b0033333632e19mr51282wri.12.1702548147402; Thu, 14 Dec 2023 02:02:27 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:52 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-13-tabba@google.com> Subject: [PATCH v3 12/17] KVM: arm64: Use generated FGT RES0 bits instead of specifying them From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020229_571200_FBF5A39A X-CRM114-Status: GOOD ( 11.06 ) 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 Now that all FGT fields are accounted for and represented, use the generated value instead of manually specifying them. For __HFGWTR_EL2_RES0, however, there is no generated value. Its fields are subset of HFGRTR_EL2, with the remaining being RES0. Therefore, add a mask that represents the HFGRTR_EL2 only bits and define __HFGWTR_EL2_* using those and the __HFGRTR_EL2_* fields. No functional change intended. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_arm.h | 34 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index b0dc3249d5cd..bd20d27f1b33 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -344,34 +344,32 @@ * Once we get to a point where the two describe the same thing, we'll * merge the definitions. One day. */ -#define __HFGRTR_EL2_RES0 BIT(51) +#define __HFGRTR_EL2_RES0 HFGxTR_EL2_RES0 #define __HFGRTR_EL2_MASK GENMASK(49, 0) #define __HFGRTR_EL2_nMASK (GENMASK(63, 52) | BIT(50)) -#define __HFGWTR_EL2_RES0 (BIT(51) | BIT(46) | BIT(42) | BIT(40) | \ - BIT(28) | GENMASK(26, 25) | BIT(21) | BIT(18) | \ +/* + * The HFGWTR bits are a subset of HFGRTR bits. To ensure we don't miss any + * future additions, define __HFGWTR* macros relative to __HFGRTR* ones. + */ +#define __HFGRTR_ONLY_MASK (BIT(46) | BIT(42) | BIT(40) | BIT(28) | \ + GENMASK(26, 25) | BIT(21) | BIT(18) | \ GENMASK(15, 14) | GENMASK(10, 9) | BIT(2)) -#define __HFGWTR_EL2_MASK (GENMASK(49, 47) | GENMASK(45, 43) | \ - BIT(41) | GENMASK(39, 29) | BIT(27) | \ - GENMASK(24, 22) | GENMASK(20, 19) | \ - GENMASK(17, 16) | GENMASK(13, 11) | \ - GENMASK(8, 3) | GENMASK(1, 0)) -#define __HFGWTR_EL2_nMASK (GENMASK(63, 52) | BIT(50)) - -#define __HFGITR_EL2_RES0 (BIT(63) | BIT(61)) +#define __HFGWTR_EL2_RES0 (__HFGRTR_EL2_RES0 | __HFGRTR_ONLY_MASK) +#define __HFGWTR_EL2_MASK (__HFGRTR_EL2_MASK & ~__HFGRTR_ONLY_MASK) +#define __HFGWTR_EL2_nMASK (__HFGRTR_EL2_nMASK & ~__HFGRTR_ONLY_MASK) + +#define __HFGITR_EL2_RES0 HFGITR_EL2_RES0 #define __HFGITR_EL2_MASK (BIT(62) | BIT(60) | GENMASK(54, 0)) #define __HFGITR_EL2_nMASK GENMASK(59, 55) -#define __HDFGRTR_EL2_RES0 (BIT(49) | BIT(42) | GENMASK(39, 38) | \ - GENMASK(21, 20) | BIT(8)) +#define __HDFGRTR_EL2_RES0 HDFGRTR_EL2_RES0 #define __HDFGRTR_EL2_MASK (BIT(63) | GENMASK(58, 50) | GENMASK(48, 43) | \ GENMASK(41, 40) | GENMASK(37, 22) | \ GENMASK(19, 9) | GENMASK(7, 0)) #define __HDFGRTR_EL2_nMASK GENMASK(62, 59) -#define __HDFGWTR_EL2_RES0 (BIT(63) | GENMASK(59, 58) | BIT(51) | BIT(47) | \ - BIT(43) | GENMASK(40, 38) | BIT(34) | BIT(30) | \ - BIT(22) | BIT(9) | BIT(6)) +#define __HDFGWTR_EL2_RES0 HDFGWTR_EL2_RES0 #define __HDFGWTR_EL2_MASK (GENMASK(57, 52) | GENMASK(50, 48) | \ GENMASK(46, 44) | GENMASK(42, 41) | \ GENMASK(37, 35) | GENMASK(33, 31) | \ @@ -379,12 +377,12 @@ GENMASK(8, 7) | GENMASK(5, 0)) #define __HDFGWTR_EL2_nMASK GENMASK(62, 60) -#define __HAFGRTR_EL2_RES0 (GENMASK(63, 50) | GENMASK(16, 5)) +#define __HAFGRTR_EL2_RES0 HAFGRTR_EL2_RES0 #define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0)) #define __HAFGRTR_EL2_nMASK 0UL /* Similar definitions for HCRX_EL2 */ -#define __HCRX_EL2_RES0 (GENMASK(63, 25) | GENMASK(13, 12)) +#define __HCRX_EL2_RES0 HCRX_EL2_RES0 #define __HCRX_EL2_MASK (BIT(6)) #define __HCRX_EL2_nMASK (GENMASK(24, 14) | GENMASK(11, 7) | GENMASK(5, 0)) From patchwork Thu Dec 14 10:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492820 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 C0000C4167D for ; Thu, 14 Dec 2023 11:17:05 +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:Message-ID: References:Mime-Version: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=3Kiy7d8QfTeVTwgRn61NqhMo9KVmeprcHWH3ENjN4Ww=; b=MyuAsYvfm61iH+oNUHL7Lm6XLl Bph/FExXh7VLT0hGbcNKmcg88Rm8YkzL0G3Q5X9f26vlNwn6dCAfYI2IOc4KbqZnoCy1BR348Q0x/ jB4XMhcQJQ2hPwGd60nwTIR8wDjzy6LlGVGqrNf3346oO9K0zKis2wcncola5LycCISFvxrEepoTT lqQWHRuRXEnBT6JCTcJsD9X9l5svyi71j53hAz4I7nONHAkW+MdqkZ23iJLu3DdB847TAsPEWeZc7 JADt1pcHwRsqRTJmpLNv+BhmM8O4BqJm8bIFFpV86wR7QDec+e8qZboBkqFfca+Q5+TKQMToDLstt F3Wx+I/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjhl-0000PE-0J; Thu, 14 Dec 2023 11:16:37 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiY3-00HP03-1M for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:33 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-33331e69698so6595960f8f.1 for ; Thu, 14 Dec 2023 02:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548149; x=1703152949; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xiH9cCOHpECfluleYwHnu/Lcc0lTQuy3GE63dgctBzU=; b=iZhGh4S6adRO3uoztxz3FdOXtnsE9ox8uipT0kw2IvvsV2H7VKHCBIetwj4Ss5qCzL 7owtTFEhiHpuzdhx1ft4xChZ0MacGZqOn0nY6kyGt6xI4Dur1WIS5fxPBUMiSUSskYjk +schs3UU633SvL+oW7MCGAvVe2tG+i9l9VUSW/kjV7l6XaKnLW0JQ25938OPxU0PL8es AqnTZIV6P5N3JBIWqiRYywJoJnqZJvciifIVobPVhswjn4c0+REz54wV/1ZmjtdtM11P tS4zNg9w9yLAkq0uIeWLksonaGMbQXnEBQ0NEgp4TAs2iQhtdvMBFPRnnFmZlxLb8yy3 LykA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548149; x=1703152949; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xiH9cCOHpECfluleYwHnu/Lcc0lTQuy3GE63dgctBzU=; b=DcVdtegie0NKQBPLSBIA90zmr3li8Yxghp4mYWDNAjoGEHfP4JQkMm4P6oRrGz2VIv G5WUYbLyxcI1+ewLEo/dOAuNC5bdwtC8/On7tnsiHe4ry8LJ+E7mLAXmz3gzHFyCYli9 naEKXrnoNkYnmpSocADIiGoUH/bWIrA3qHpZZcuKn8AxsdZ0bgVSFHpDZ1AnAYZurVyV eE6K5IRNgB+lGUZc6GAJvgVphAWC56nRkNFxxBdgoCGQhO/ypYDqa/cFZYqviLoxvevE uXSovLtqSamwdYAietOrbqDwkJiMe1eMPncDZ9YF1cfv/a9n+qNm+F1tfjxiERw+UYQF bSuA== X-Gm-Message-State: AOJu0YzW6LL5tzQ0fRY3uCNnDL3vjO2fyCfYQhUN9ZcJ2BrZPH0SzBoc sHRKPypFaHpmgoKc8hw9mVmkrXwOlw== X-Google-Smtp-Source: AGHT+IHX75xTL+XE/RnHwJsq2XGhisxwaOMfWGYxWgvAlywICs0euh4HZY2sx82xHWV+xO1t1Aiaso36uw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5d:4246:0:b0:336:4ad5:60eb with SMTP id s6-20020a5d4246000000b003364ad560ebmr1093wrr.7.1702548149458; Thu, 14 Dec 2023 02:02:29 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:53 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-14-tabba@google.com> Subject: [PATCH v3 13/17] KVM: arm64: Define FGT nMASK bits relative to other fields From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020231_516313_C850727F X-CRM114-Status: UNSURE ( 9.00 ) 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 Now that RES0 and MASK have full coverage, no speed to manually encode nMASK. Calculate it relative to the other fields. No functional change intended. Signed-off-by: Fuad Tabba --- arch/arm64/include/asm/kvm_arm.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index bd20d27f1b33..b7a9fe36bb59 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -346,7 +346,7 @@ */ #define __HFGRTR_EL2_RES0 HFGxTR_EL2_RES0 #define __HFGRTR_EL2_MASK GENMASK(49, 0) -#define __HFGRTR_EL2_nMASK (GENMASK(63, 52) | BIT(50)) +#define __HFGRTR_EL2_nMASK ~(__HFGRTR_EL2_RES0 | __HFGRTR_EL2_MASK) /* * The HFGWTR bits are a subset of HFGRTR bits. To ensure we don't miss any @@ -357,17 +357,17 @@ GENMASK(15, 14) | GENMASK(10, 9) | BIT(2)) #define __HFGWTR_EL2_RES0 (__HFGRTR_EL2_RES0 | __HFGRTR_ONLY_MASK) #define __HFGWTR_EL2_MASK (__HFGRTR_EL2_MASK & ~__HFGRTR_ONLY_MASK) -#define __HFGWTR_EL2_nMASK (__HFGRTR_EL2_nMASK & ~__HFGRTR_ONLY_MASK) +#define __HFGWTR_EL2_nMASK ~(__HFGWTR_EL2_RES0 | __HFGWTR_EL2_MASK) #define __HFGITR_EL2_RES0 HFGITR_EL2_RES0 #define __HFGITR_EL2_MASK (BIT(62) | BIT(60) | GENMASK(54, 0)) -#define __HFGITR_EL2_nMASK GENMASK(59, 55) +#define __HFGITR_EL2_nMASK ~(__HFGITR_EL2_RES0 | __HFGITR_EL2_MASK) #define __HDFGRTR_EL2_RES0 HDFGRTR_EL2_RES0 #define __HDFGRTR_EL2_MASK (BIT(63) | GENMASK(58, 50) | GENMASK(48, 43) | \ GENMASK(41, 40) | GENMASK(37, 22) | \ GENMASK(19, 9) | GENMASK(7, 0)) -#define __HDFGRTR_EL2_nMASK GENMASK(62, 59) +#define __HDFGRTR_EL2_nMASK ~(__HDFGRTR_EL2_RES0 | __HDFGRTR_EL2_MASK) #define __HDFGWTR_EL2_RES0 HDFGWTR_EL2_RES0 #define __HDFGWTR_EL2_MASK (GENMASK(57, 52) | GENMASK(50, 48) | \ @@ -375,16 +375,16 @@ GENMASK(37, 35) | GENMASK(33, 31) | \ GENMASK(29, 23) | GENMASK(21, 10) | \ GENMASK(8, 7) | GENMASK(5, 0)) -#define __HDFGWTR_EL2_nMASK GENMASK(62, 60) +#define __HDFGWTR_EL2_nMASK ~(__HDFGWTR_EL2_RES0 | __HDFGWTR_EL2_MASK) #define __HAFGRTR_EL2_RES0 HAFGRTR_EL2_RES0 #define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0)) -#define __HAFGRTR_EL2_nMASK 0UL +#define __HAFGRTR_EL2_nMASK ~(__HAFGRTR_EL2_RES0 | __HAFGRTR_EL2_MASK) /* Similar definitions for HCRX_EL2 */ #define __HCRX_EL2_RES0 HCRX_EL2_RES0 #define __HCRX_EL2_MASK (BIT(6)) -#define __HCRX_EL2_nMASK (GENMASK(24, 14) | GENMASK(11, 7) | GENMASK(5, 0)) +#define __HCRX_EL2_nMASK ~(__HCRX_EL2_RES0 | __HCRX_EL2_MASK) /* Hyp Prefetch Fault Address Register (HPFAR/HDFAR) */ #define HPFAR_MASK (~UL(0xf)) From patchwork Thu Dec 14 10:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492821 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 718E1C4167B for ; Thu, 14 Dec 2023 11:17:06 +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:Message-ID: References:Mime-Version: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=Recbsr6tnh++Mv/OoSsoLts1WmSHU+haFdDps7/2ks4=; b=lducNzUXxaTGn2eCgjD44PU9r1 SzqJKrsRx8lozRQmANtPBduaBc4FdqymSyDLZeoJacbc+JiLuMaT5GksLg/A110/iGSXLndTiBypo b6FDHN6Mm+HCgnF3VTEuFk9pG3HWBronqQKKSSpoSOl71QfnjDZba7u9nZGtItZbCnTnvYv4D4p9T kiOljrKFCfDjKICApE0EyYck+7EBZqLit2XL6gHKB6uvMB5UDGhyb9XuVFHOO2Pa4cokwhxYjuK7S dNKenwV2cKuVNtKVqO3Xteb9qpyQaEo+SiI2ORs1x3cOa2Gxgb+2qjxY4XiKMAmJ6yvwPuzpX12KI NkJvt8UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjhl-0000PY-20; Thu, 14 Dec 2023 11:16:37 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiY5-00HP1W-0t for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:34 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dbcda1ff95bso1291352276.3 for ; Thu, 14 Dec 2023 02:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548152; x=1703152952; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BZpm5g8sXqlgN71zqSoD3PYKLpgzzVAPPBQdv9SzS9U=; b=CPDvaLS8OmFBEYW5Yg6ZQnWOHqTYDViBZL3zXkMN/b4dem3IdMLGAkKnw35emwl9WU 8t3t15jPeaOfliXP5v9bzzJb/sZUQ4GiUJ72iCriq9xRocMpPUbeK4AblgIBaMlHevhy KfU95opCkcBNDE8fmQtXZtI67rzducGqGbgU+es1gdxXOKALZIa5djjXGo8t1Rcz0Bz8 d6yrPeLvyF6jb3UdtCLiWQl0/yxRCwdDCPjUR4CIrXimyX1XsgZiJk0QtcM3EY6nUORE g9ZAun8YEEkw2njcTkyjX9OP6AQJ6a1ZxYySAK/GjPD4no8mvvwi2StDiOqpMhrcNbPs lmgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548152; x=1703152952; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BZpm5g8sXqlgN71zqSoD3PYKLpgzzVAPPBQdv9SzS9U=; b=PkSQlBn1otS/TgYdEu9SfDs5yiCjpAc90xVIJkAl2d98/0SoSg2y9YPp5lc0bI33iS RrIgcBF/PVrWCLwUzhzKKDbI2I23r1e5QFOW9zcho9H7Toik+G8wW7Cy7ZonDgvlKYFX RVJJ/hIVQsUK2dOTs9lc5nLBUex094Xpgts6+7ef0A+vlfXBhpgfMjPSfhvqS0IsMqFr CI8422G7QxFJOtBob2Cuo7s4eTreLy49eXN5ALkqi+Z0RE6445i6Om33v8hbCyalMjsO ccvT/70FsqNBGiOrmchVwz0P0D9EV18rNjalBXJFMHMFa/zffz/79pVcNN4s/6jE0sga oTnQ== X-Gm-Message-State: AOJu0YzZwuMLv88ZOuESD3gg/6HAa/aO6RseSGRimUPYfoiUDW1+9PRR dMY0qBu6z7t1c2EsCRetJ3lp+fMbhA== X-Google-Smtp-Source: AGHT+IF6Akn1Pi5DCUhyiJjAZLduSqaHqIoZSn6di1DIm8HQc07sCgOSlwvtGjmu28U/J1q4cm0p0M6luQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:6902:150:b0:da0:3da9:ce08 with SMTP id p16-20020a056902015000b00da03da9ce08mr109580ybh.10.1702548151743; Thu, 14 Dec 2023 02:02:31 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:54 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-15-tabba@google.com> Subject: [PATCH v3 14/17] KVM: arm64: Macros for setting/clearing FGT bits From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020233_324994_EE467EBD X-CRM114-Status: GOOD ( 11.78 ) 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 There's a lot of boilerplate code for setting and clearing FGT bits when activating guest traps. Refactor it into macros. These macros will also be used in future patch series. No functional change intended. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/include/hyp/switch.h | 60 +++++++++---------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 17ce40f5b006..e223fc0d5193 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -79,6 +79,23 @@ static inline void __activate_traps_fpsimd32(struct kvm_vcpu *vcpu) clr |= ~hfg & __ ## reg ## _nMASK; \ } while(0) +#define update_fgt_traps_cs(reg, clr, set) \ + do { \ + struct kvm_cpu_context *hctxt = \ + &this_cpu_ptr(&kvm_host_data)->host_ctxt; \ + u64 val, c = 0, s = 0; \ + \ + ctxt_sys_reg(hctxt, reg) = read_sysreg_s(SYS_ ## reg); \ + compute_clr_set(vcpu, reg, c, s); \ + val = __ ## reg ## _nMASK; \ + val |= (s | set); \ + val &= ~(c | clr); \ + write_sysreg_s(val, SYS_ ## reg); \ + } while(0) + +#define update_fgt_traps(reg) \ + update_fgt_traps_cs(reg, 0, 0) + /* * Validate the fine grain trap masks. * Check that the masks do not overlap and that all bits are accounted for. @@ -146,45 +163,10 @@ static inline void __activate_traps_hfgxtr(struct kvm_vcpu *vcpu) if (!vcpu_has_nv(vcpu) || is_hyp_ctxt(vcpu)) return; - ctxt_sys_reg(hctxt, HFGITR_EL2) = read_sysreg_s(SYS_HFGITR_EL2); - - r_set = r_clr = 0; - compute_clr_set(vcpu, HFGITR_EL2, r_clr, r_set); - r_val = __HFGITR_EL2_nMASK; - r_val |= r_set; - r_val &= ~r_clr; - - write_sysreg_s(r_val, SYS_HFGITR_EL2); - - ctxt_sys_reg(hctxt, HDFGRTR_EL2) = read_sysreg_s(SYS_HDFGRTR_EL2); - ctxt_sys_reg(hctxt, HDFGWTR_EL2) = read_sysreg_s(SYS_HDFGWTR_EL2); - - r_clr = r_set = w_clr = w_set = 0; - - compute_clr_set(vcpu, HDFGRTR_EL2, r_clr, r_set); - compute_clr_set(vcpu, HDFGWTR_EL2, w_clr, w_set); - - r_val = __HDFGRTR_EL2_nMASK; - r_val |= r_set; - r_val &= ~r_clr; - - w_val = __HDFGWTR_EL2_nMASK; - w_val |= w_set; - w_val &= ~w_clr; - - write_sysreg_s(r_val, SYS_HDFGRTR_EL2); - write_sysreg_s(w_val, SYS_HDFGWTR_EL2); - - ctxt_sys_reg(hctxt, HAFGRTR_EL2) = read_sysreg_s(SYS_HAFGRTR_EL2); - - r_clr = r_set = 0; - compute_clr_set(vcpu, HAFGRTR_EL2, r_clr, r_set); - - r_val = __HAFGRTR_EL2_nMASK; - r_val |= r_set; - r_val &= ~r_clr; - - write_sysreg_s(r_val, SYS_HAFGRTR_EL2); + update_fgt_traps(HFGITR_EL2); + update_fgt_traps(HDFGRTR_EL2); + update_fgt_traps(HDFGWTR_EL2); + update_fgt_traps(HAFGRTR_EL2); } static inline void __deactivate_traps_hfgxtr(struct kvm_vcpu *vcpu) From patchwork Thu Dec 14 10:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492824 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 7DBB2C46CA2 for ; Thu, 14 Dec 2023 11:17:06 +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:Message-ID: References:Mime-Version: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=AyaKOiRQyrvPZZwIcBR7GQ0/Qerg6JZLqtUlMKBC3T0=; b=IEXRzEnhF6UadABjotFCKZRwLr fclCY/rXU0yiZsD+3pUkmxcEICK/0rI6RtvWMQ8BwCyfjHmIwR4xku9PZaoWAlSL3TFAeNu0/FkQz x1O6sNQrlAH5wYy2yIGu2Veu1xs965Uknknk3XRPNccHfLGT9OgQ2mNtHQdJb4kewpS+lQPv48fLx 9Sv7ZdnHNrU5KtRMwuuZJms6+DtlpMMk3XIByv1sW5OY88Lv2bmON2QeiQXJhLUkqtJVhuTQrOF6q E8LuK7Z3Lo8wbd7W/koKVU3TFmbRLlV/b5/cyLh99iz5pIJRVKu9JURhHPf2B0c3d2GCI595GiDOQ ODF4ldWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjhm-0000Pr-0R; Thu, 14 Dec 2023 11:16:38 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiY7-00HP2y-19 for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:36 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dbcd721b366so346767276.0 for ; Thu, 14 Dec 2023 02:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548154; x=1703152954; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=S1+IuL8DTNb6t5XDOnXjUzV0e48iypX1iDtmuw3RN+0=; b=WzI80vpVjLuGf9QJMrkuXjGj7nkKiy/dl1uT7MKdUx7WNUZBb/heZZl+5O+zmfFcg2 tnhb0P7LC0asQ7XrYeiz4nCpYPQrEBvSkFUew60QOJFeMtjp4BNd1/cdTim2oRUT7mDx UYBobAKq9SckqPzRq3U6wVUbcHQX+Lna0Ux21R6nTOSMweNliBqimurKcZ83l/DPqGe7 +Xlyrn8CF5/VoXW9AiW7jpxW4A5Lr7r41wLFLWDrO6dY/e3BJ/RPAGMW3MhadoviMQMc UUrHDOtX9pqHULxWTXNLJsFg43nTOj2ofkAnYbk761tagzQ1n6f8jxRR088ZhJ4n12FJ IHCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548154; x=1703152954; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S1+IuL8DTNb6t5XDOnXjUzV0e48iypX1iDtmuw3RN+0=; b=Aqmy2T8tKV7E1YoCXKCu+maSqdzB6DC2Y0P590g6fWP/74tFREuQ3sck55TJIIyPT0 pHccBwar/rsYXTvIZl+EOQ2dxjg7qPbI0S6pcDumPgMb6NzRR8BXBfTfBBEFymN/zcRi jfYS3r2S7B9qbqd5wACI0zRCPhRoqwQFCkxn0K7Bo9glQr6i3HJnXnwwkN9sk4Tvim02 hrD/5TRT3KiyxdvTEch90lLm8QU5XWwQ5nQ3rbCQy2Zi4VgDyTbCskhOHgDCheJcNPsJ 63CN10ZaSM/NRQyNybpd0ZyvyW38PW5A/i9FEHZD2/yq3DbGKF1Zllfdg7yj6E4tNrzL 60Kg== X-Gm-Message-State: AOJu0YxZTnR2zFYJylTMMfkB2DG+/t5cG/P4Iqy9E14ca8zQWwClOHkD OunZjgQB2Y2ymEuCq7X5anmmsKB+bg== X-Google-Smtp-Source: AGHT+IFYC31qCWJ06bIumj+WQ40j9UIE6wLj/c88RXH+XdggRYNwnvugeJ9GwrMi29Nj5+bhLHACVDAgRw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a25:1307:0:b0:db5:4a00:a153 with SMTP id 7-20020a251307000000b00db54a00a153mr159337ybt.4.1702548153946; Thu, 14 Dec 2023 02:02:33 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:55 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-16-tabba@google.com> Subject: [PATCH v3 15/17] KVM: arm64: Fix which features are marked as allowed for protected VMs From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020235_404792_D7CFAEBE X-CRM114-Status: GOOD ( 10.38 ) 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 Cache maintenance operations are not trapped for protected VMs, and shouldn't be. Mark them as allowed. Moreover, features advertised by ID_AA64PFR2 and ID_AA64MMFR3 are (already) not allowed, mark them as such. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/include/nvhe/fixed_config.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h b/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h index e91922daa8ca..8d97dff4bb7b 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h +++ b/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h @@ -69,6 +69,8 @@ ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_SSBS) \ ) +#define PVM_ID_AA64PFR2_ALLOW 0ULL + /* * Allow for protected VMs: * - Mixed-endian @@ -101,6 +103,7 @@ * - Privileged Access Never * - SError interrupt exceptions from speculative reads * - Enhanced Translation Synchronization + * - Control for cache maintenance permission */ #define PVM_ID_AA64MMFR1_ALLOW (\ ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_HAFDBS) | \ @@ -108,7 +111,8 @@ ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_HPDS) | \ ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_PAN) | \ ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_SpecSEI) | \ - ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_ETS) \ + ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_ETS) | \ + ARM64_FEATURE_MASK(ID_AA64MMFR1_EL1_CMOW) \ ) /* @@ -133,6 +137,8 @@ ARM64_FEATURE_MASK(ID_AA64MMFR2_EL1_E0PD) \ ) +#define PVM_ID_AA64MMFR3_ALLOW (0ULL) + /* * No support for Scalable Vectors for protected VMs: * Requires additional support from KVM, e.g., context-switching and From patchwork Thu Dec 14 10:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492823 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 A4B09C41535 for ; Thu, 14 Dec 2023 11:17:06 +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:Message-ID: References:Mime-Version: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=LfDG+/OI4T7UGtBOPD1DAxI0djJ7SMuz2kAg9wy+5g4=; b=U+kZQ8jtJXNLsNy+uYV9CuLojC gpyecvKQpx4/dOPMmj78XBxkp08iHkcpkTE6OSt782VVNZzlW+KPSRUQGW/qFX+4AdX4MAdDLHdJs 2qenxRSGKwrGe00FL7hUTyIs8w1hdgIDmY8hZPmDnl3F/XJvaq6dr88cwe9Ux8VZwp5r5Fv2xV2E+ BJnR3JE3MJt0VCpwK4gDWU9Z8Jz/w/f4pQWksEz9NbcSGNT6ETNqb3HYXWQBU8RcFd4KRwUpZadIH HOUzKcFviBACmZ/NMqhyFisfudTnd+NNAHhB4/xr05l61TZ+yBBEY2gPEgUMspiSkdcMmCdHhs5R4 zjDGw7yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjhm-0000QJ-2D; Thu, 14 Dec 2023 11:16:38 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiYA-00HP4j-1b for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:42 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-33608afc552so6002745f8f.2 for ; Thu, 14 Dec 2023 02:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548156; x=1703152956; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DxM0XHeehpr+WPJP1Pzkg4drlsNFy3fN21V8Kb3LPPA=; b=GIWYgKTFObDRP+haHFnBKRt1QkWofRxM+5S7fke/TfGK6d41MVtYn3wrKb4TEeFxUa mrGamTxgGyGfs1BBlIvWUDs7kDzGRzmkKl3UeOGl0aW4iQkNeGm5t/IHyv6++PETLDh/ ldfsnWTuXNdX+FSAUXopgwVImxdxk/HLnC45CjUTci1lBm5dqcErByKm01yxeMMR7UXL k0yJjHRU9ybgvbh18MTUvUtYU6JyQOxqDuN9x+OiXS/2GI3txSXBaQm4Ezw8Mc3XQkbt ccPUSx4Xw6ATEUiavyHAmdjgA9LNHmJnI/Ss3ijmj7d5y73LFxch11QGsZEP4hfkD/wC Agmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548156; x=1703152956; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DxM0XHeehpr+WPJP1Pzkg4drlsNFy3fN21V8Kb3LPPA=; b=kMTHcSoprsvb9upqWSUrAmrI3DsOwYKSwUn/OeyK4Q7elfnajP5hMaXMeBmS3QJXP9 l06RMBKUqN0IGryoTzcxav9mpkRxkZ0T7+oHalm95RsGkFFfyKCA+OC8wT8EglwyCsf5 XBmrjwZ28ImrZTczGzPPs9eqB2JntscpTUgziDsXJCo49J0mHuu4Pa8nVsM/cfHAN0eH GvEQRUGJpnNIuLlI2zMk/Uv+vjUNZTZPlEpn/2AlMEY65MpMybIBwifM5Mj47wD6YJ4e lTUM3lobl6rSOY0I2CbZqAgr2xLDUw6bOnvROA+dAvSywgwx5fW+kWFPnh4/GkUAUI7e KbFw== X-Gm-Message-State: AOJu0Yy84xzl0zM0RvKOR7zGGj09HM7HzRwaTxJUJD4QSiUVCqPXDKJd TFr5Dp89jIyl2BLncpp5HcGlLNBo+A== X-Google-Smtp-Source: AGHT+IHRZfkX+kRwxAcAgeOYuqBVIq7qh6v7y8TD4vtcPCdnrGYYlwGO4zqQN1aoI/8Pp/ExfSE/vt6lxQ== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a5d:4b06:0:b0:336:4a97:9f70 with SMTP id v6-20020a5d4b06000000b003364a979f70mr1374wrq.5.1702548156209; Thu, 14 Dec 2023 02:02:36 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:56 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-17-tabba@google.com> Subject: [PATCH v3 16/17] KVM: arm64: Mark PAuth as a restricted feature for protected VMs From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020238_557317_E5EF2D12 X-CRM114-Status: UNSURE ( 9.74 ) 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 Protected VMs will only support basic PAuth (FEAT_PAuth). Mark it as restricted to ensure that later versions aren't supported for protected guests. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/include/nvhe/fixed_config.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h b/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h index 8d97dff4bb7b..51f043649146 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h +++ b/arch/arm64/kvm/hyp/include/nvhe/fixed_config.h @@ -184,10 +184,18 @@ ARM64_FEATURE_MASK(ID_AA64ISAR0_EL1_RNDR) \ ) +/* Restrict pointer authentication to the basic version. */ +#define PVM_ID_AA64ISAR1_RESTRICT_UNSIGNED (\ + FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_APA), ID_AA64ISAR1_EL1_APA_PAuth) | \ + FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_API), ID_AA64ISAR1_EL1_API_PAuth) \ + ) + +#define PVM_ID_AA64ISAR2_RESTRICT_UNSIGNED (\ + FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_APA3), ID_AA64ISAR2_EL1_APA3_PAuth) \ + ) + #define PVM_ID_AA64ISAR1_ALLOW (\ ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_DPB) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_APA) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_API) | \ ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_JSCVT) | \ ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_FCMA) | \ ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_LRCPC) | \ @@ -202,8 +210,8 @@ ) #define PVM_ID_AA64ISAR2_ALLOW (\ + ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_ATS1A)| \ ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_GPA3) | \ - ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_APA3) | \ ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_MOPS) \ ) From patchwork Thu Dec 14 10:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13492822 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 D6D08C10F13 for ; Thu, 14 Dec 2023 11:17:06 +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:Message-ID: References:Mime-Version: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=WFgbwxC2KaDNRppnrs5ddS1tXF4348CcCVMDhBvEIDc=; b=0zDwmPUMXkhDwbfWhsuqocno29 G8zZLU9bwqr6S5tptFaLVFp1eodeJrXC4urK3y49xIIoo7k9hOn22HydxP0bx+Lq7OVZmkginUo8o UBHBk1yAkuH3YmgVsF1ypqSTGuS8tk1Xo3i9FisMm7bUgXKPfsW8QBMC6TNs4Bahcl1BCH98aCxtJ oY+t66GSAtMLtDmtxgdkM3c9SAF7kS2q7lZZKaqQEMmb2T92ZacDik2BFZe7s4hYyzRY/QBP98kA/ tzi6deX6zRbu2f4Idst8za9j7KTcY5k7OkIKNiVmFG8BLGUivlhj7Pm0Dtqty8Bdi4imqPqbEuuRm 1nh0mvgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDjhn-0000Qj-0p; Thu, 14 Dec 2023 11:16:39 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDiYC-00HP60-0d for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 10:02:43 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dbcdf587bd6so955760276.0 for ; Thu, 14 Dec 2023 02:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702548158; x=1703152958; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dQ3NwtPLUek23R4jO5ryAbc+RXV6V+XaVPuMrIGMVy8=; b=a0gv49Zqqj5pbP+lwkDIAEaC3OafFI8H6j36nHDieTKzQo1cAUkoWtGJui/PnUVNW5 bGfnGTNx27s7gtTaGh6F/dTPoSwClSpnPno1HNBS2WoPwIudmortImKL3ixnUnEA5YW/ yZQ5wDJfT9qw3TGWxNzcC8YyHKWosS1jnAxM0kqHSRty341afdPvYUVHapqXAtQ1kbdK +RGfu3kj5ycFL0a0ChroE9R/ky9FSOn2Ostgr72hOSy+9quV2oLlIFEOxhiAT4O2vVxf cQG4AZz/fo6qw+X7CNz0UFmYyZUdHeBMHI6Hn6Z8EGUI95UOO8hf1uGP13gWWvyzj5U7 DX3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702548158; x=1703152958; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dQ3NwtPLUek23R4jO5ryAbc+RXV6V+XaVPuMrIGMVy8=; b=TIclmizven1RKbelnUOpqo38KXCnLdHhS4lldv8XtFVWivBIr9c7oa8crI+hRzIiFB 3HhX/0xAHkbpDhYdy6RGRqQaSPBS5+3v4+paLZuCm244Uq5+yeIyR9KhfVMO9BqtAsu1 hPK30/zFR8cq0y2H9kl/folFuXugUIevcjZrgc9vKjwc2E9DqlSzpdRH7IWMfAh+G/pv YKOGPs92XYdHamTkLbZmVIPnaDcVJQdM/blUizJfKqTsI1kgHFm9ChBo8Np+3rRCRmfU bxa2OM4AEmyZIEm7v6qXsS7+abF2fyk34LV7RE8F8UfRIhlLkuGm/gSz9gdZh/OE5ZUy s7Tw== X-Gm-Message-State: AOJu0Yyou9NvjNA3DTNLPVyYROIYA7kR8Sf3aoqmoHefIeR73IhLT9j4 r4SKyUly09iYbubGdPi1JUy2jMYB2g== X-Google-Smtp-Source: AGHT+IFegaKEFW4myHOQsqPxjgTrzClJ0RE+4TCPqKKb1gBoPmBB99hEXMdBnUjfibDl/STy1jRxn+C/Ig== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a25:8a09:0:b0:db5:3676:74dd with SMTP id g9-20020a258a09000000b00db5367674ddmr102624ybl.3.1702548158582; Thu, 14 Dec 2023 02:02:38 -0800 (PST) Date: Thu, 14 Dec 2023 10:01:57 +0000 In-Reply-To: <20231214100158.2305400-1-tabba@google.com> Mime-Version: 1.0 References: <20231214100158.2305400-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214100158.2305400-18-tabba@google.com> Subject: [PATCH v3 17/17] KVM: arm64: Trap external trace for protected VMs From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231214_020240_257966_F8679B18 X-CRM114-Status: GOOD ( 10.33 ) 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 pKVM does not support external trace for protected VMs. Trap external trace, and add the ExtTrcBuff to make it possible to check for the feature. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index 9d23a51d7f75..84b5c3f387d8 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -136,6 +136,10 @@ static void pvm_init_traps_aa64dfr0(struct kvm_vcpu *vcpu) cptr_set |= CPTR_EL2_TTA; } + /* Trap External Trace */ + if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_ExtTrcBuff), feature_ids)) + mdcr_clear |= MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT; + vcpu->arch.mdcr_el2 |= mdcr_set; vcpu->arch.mdcr_el2 &= ~mdcr_clear; vcpu->arch.cptr_el2 |= cptr_set;