From patchwork Tue Aug 1 15:20:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 13336938 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 7B482C04A94 for ; Tue, 1 Aug 2023 15:21: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=WH9Vd47wPC9M0RN9ESqVjz7zMnz5qXe1hFkMjl7dJVA=; b=rbvRVg2wn9C1sr7v8Qk0CEO0I7 IOLzYEWerisWDxy/KjmY/6nzUVhkLbaUwZhjzo32q6sFH5+eC7NWe9+sg6mm+8g1k69zzzyl5t1GS yT7BvA2GdrzCnQfwN3/fOx+tQlNtZnMf7E+vaxyyDBVw9Vcum4pCnqdeeiq/fYoNPAPP8KdYK4cSR Zvp3ig2mJTcfI2YY52WdffyF3ex0OQ1Da14Hp87/aQG0oTCpPSNdQG9b6IXQ5++vWD8RNSOvaJNw8 8bhLF64DXDpM4LzSieNImU7Sid8FPQhWvJpw4gEORhYVYOyNF9bBrXbQfX4fEYS3TOyKihclPrUiA 8aiRMCfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQrAo-002hkK-1q; Tue, 01 Aug 2023 15:20:34 +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 1qQrAk-002hgF-2c for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 15:20:32 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d0fff3cf2d7so6554659276.2 for ; Tue, 01 Aug 2023 08:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690903229; x=1691508029; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=b/7Lgt+l6L+++1Locph+rfoqbHtbNhHaO0z9TCoQ7fA=; b=Luf11HbqJXsqK0tpJ3+Vf7M5BsSvN+4sdgT+iA5iaTwGYb83udLYbD7YLGG7D/+G34 /NR7P0ZzJ0OJ8Gd7885VO4M+zd6M6ml2nN4eTdX5MdfXaHHUdF3Z0blhLg2hkWxopmj5 21J5DRheYcsD53vj2OiJkVw/3yyXOjD1mZ7MmY6AmnpTdmcyvijI38DWiVrLiFb+vlPc nXTMtu1DrSrw3bs4tNTz4M+aC4rnuaRCCPimr+rKbe1di7FuQV9cG6mu65xztADcSNfd NQJz9ik/07luYAB3j4hG87oq7Q3FY2x5F1MD0wGAvoPzt82QqMq92BdQ6UsiSErDtKgq ZDqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690903229; x=1691508029; 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=b/7Lgt+l6L+++1Locph+rfoqbHtbNhHaO0z9TCoQ7fA=; b=Cx+i2I+1xTHALFBzh8LChi8YJZGLBGx1eiuzQ/CfdFar0KY2WcxsM9ye6mPgeonXZD CJNLZxDyo9OTptJNRPzCmbyTmoU7ykx/awV+t5I53f7BbsrxyldxwDnQr7WbEIZphHic w3X9E2hVI7G0dV+cX7wnl+ojvLFKrDG9WfQjmWRIlwm8PYMZPTiX/IYFiQ+lAi28vPsg B3W8XgaBHGpactNTXVxfMqeCMad7JJiGFJLboK//zP2tA7RKFDe8ZU4t4LP1GrGRdJ80 z59NJsPyBiZCYy8a4kMH/Y32d5x0YE0mqTTByp9QYbvL+H9lrTOMMRqXnI/9iJCGZbyC EAFQ== X-Gm-Message-State: ABy/qLb64/UxvL3cohYcT5l/l9Yb4MjVKKY+MvG/lfbv2A0IvLZNOu/J Im28I2NeLkozp1Pkrgtl+/KEPRrKxkIWxUmxvg== X-Google-Smtp-Source: APBJJlHzVwXMgVQQFdwSLT/blqJxTGWY8QTbzn3EO4lzgefNJKzxZfyyaG0mqKCJlhRCBb/Kq++VwHj9ggc+2qA52g== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a25:1446:0:b0:d31:b7c5:5170 with SMTP id 67-20020a251446000000b00d31b7c55170mr42960ybu.12.1690903229712; Tue, 01 Aug 2023 08:20:29 -0700 (PDT) Date: Tue, 1 Aug 2023 08:20:05 -0700 In-Reply-To: <20230801152007.337272-1-jingzhangos@google.com> Mime-Version: 1.0 References: <20230801152007.337272-1-jingzhangos@google.com> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230801152007.337272-10-jingzhangos@google.com> Subject: [PATCH v7 09/10] KVM: arm64: Enable writable for ID_AA64MMFR{0, 1, 2, 3}_EL1 From: Jing Zhang To: KVM , KVMARM , ARMLinux , Marc Zyngier , Oliver Upton Cc: Will Deacon , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Fuad Tabba , Reiji Watanabe , Raghavendra Rao Ananta , Suraj Jitindar Singh , Cornelia Huck , Jing Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_082030_856904_8856B127 X-CRM114-Status: GOOD ( 11.30 ) 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 Enable writable from userspace for ID_AA64MMFR{0, 1, 2, 3}_EL1. Signed-off-by: Jing Zhang --- arch/arm64/kvm/sys_regs.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 9ca23cfec9e5..67b50a088eac 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1346,9 +1346,6 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu, val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_WFxT); val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_MOPS); break; - case SYS_ID_AA64MMFR2_EL1: - val &= ~ID_AA64MMFR2_EL1_CCIDX_MASK; - break; case SYS_ID_MMFR4_EL1: val &= ~ARM64_FEATURE_MASK(ID_MMFR4_EL1_CCIDX); break; @@ -1581,6 +1578,15 @@ static int set_id_dfr0_el1(struct kvm_vcpu *vcpu, return set_id_reg(vcpu, rd, val); } +static u64 read_sanitised_id_aa64mmfr2_el1(struct kvm_vcpu *vcpu, + const struct sys_reg_desc *rd) +{ + u64 val = read_sanitised_ftr_reg(SYS_ID_AA64MMFR2_EL1); + + val &= ~ID_AA64MMFR2_EL1_CCIDX_MASK; + return val; +} + /* * cpufeature ID register user accessors * @@ -2063,10 +2069,10 @@ static const struct sys_reg_desc sys_reg_descs[] = { ID_UNALLOCATED(6,7), /* CRm=7 */ - ID_SANITISED(ID_AA64MMFR0_EL1), - ID_SANITISED(ID_AA64MMFR1_EL1), - ID_SANITISED(ID_AA64MMFR2_EL1), - ID_SANITISED(ID_AA64MMFR3_EL1), + ID_SANITISED_W(ID_AA64MMFR0_EL1), + ID_SANITISED_W(ID_AA64MMFR1_EL1), + _ID_SANITISED_W(ID_AA64MMFR2_EL1, set_id_reg, read_sanitised_id_aa64mmfr2_el1), + ID_SANITISED_W(ID_AA64MMFR3_EL1), ID_UNALLOCATED(7,4), ID_UNALLOCATED(7,5), ID_UNALLOCATED(7,6),