From patchwork Mon Feb 14 06:57:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12745063 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 C4363C433EF for ; Mon, 14 Feb 2022 07:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=t1Qcf0GaBUamgMEZJBQmVCJQC7gnqLtn8SFweVTpeqY=; b=fJ4WzHlq693XalkFi+mCT0Ac8D xSm1AAmd2qoD3ovkOmjct0/UwNIbK5JrbUDPDvnAspZmHkouX+2pnqGgMknG1Gq2HUUSzIRz+1nWo DDRuSJhEOflbMHwqqVPeDq0VNA6lQhVy3zugyeImGKhDH2dQ2jN4B62C3tkPb7b/6lPPSfoZRZ+qs o+6qoEvhCeE8zWfAWp/+99aiwxgHkH7uGrBPu9w4LS0w8QSQtwayLYw7roHGtAYxkVEq6Cv6Wy7ZB PxsBjTtAv3VpgizwBB5rD59cYM/5Oxcu2NoY31bjAkbrTmLVWvImOLrRxwjFoxDjsJnBWl2Vcf4yt 73h0GurQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJVZY-00Dcvc-Km; Mon, 14 Feb 2022 07:14:58 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJVMV-00DXW3-Nc for linux-arm-kernel@lists.infradead.org; Mon, 14 Feb 2022 07:01:32 +0000 Received: by mail-pl1-x64a.google.com with SMTP id j1-20020a170903028100b0014b1f9e0068so5777655plr.8 for ; Sun, 13 Feb 2022 23:01:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=1nsgNzH+YpfR3/KlbrupFdkkNs/4tvboqaVeY8OSkcA=; b=Uzrf4k8tdsN8iZk1o4Z1sprsLA1ZDIULzNZcfKvd8PPrrmESS5rysT77OyuSEML4DF U+5KaNW1vZk4LEbccSoj8bsf7DakaW2MOusPTwkA6AnYJdltLtH9e+Ur/jj6FnKaSXKh w8Ygcb7Ge32vFXcMJxmtWjb0wlLab22kQyymXpYmZOE/GBiqqvZeBwz9HPTFVkQSXKZ9 2BpaE2lLws1UG9FMApBj1HgD73tjL9mrvvH8rtVIVeW4+InQUIx9yB+ESPmrBJgfSkor v698uTnpwEjjkaP3DqhEzGLB6oSx2h5oSNbJTFcf2ZsjxZ8MuLPpPlszv4nC4g9HCC5A iByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1nsgNzH+YpfR3/KlbrupFdkkNs/4tvboqaVeY8OSkcA=; b=R5P+goYMj8lyCrjrYVuvZdDtqBi27lOjxQdKIjuvoxnv9FhhnPDcG8uRaqCZlSAAI1 NMt5rWK9f+sYRpsNB5gJ8mGIsG53M1oYfZFdPmzGM7af+BuygWiAeg1bVCAqQMz4WLpm Mu4HCvNj5naLoH7d3+t0ICfyZ/6EGqbhemGdDB2/tI6u6JGqG9pK1xP6S4AG0uUBHrVl I/7VIe6RTFOFZ1Tq1YDLUFktN1S8+poLko4/25LF47xoigooVk6PhowQSBqmEURXIHvD 0XfuXL7Eju/mPhZqEA8PNmW8+9aFumlnj/z321DTo4Xa0UNjKao8Nt9qrXGcVPmvAm0U BatQ== X-Gm-Message-State: AOAM530oNzKWqYpzU25ufK7A4kt7tyCS56NvGJmKsWDDmApj77oAyDVC YPHwkBkTRg8Qq2JDeUiqdDPJ/lbjrWY= X-Google-Smtp-Source: ABdhPJwSnhJG8X92VE6HuDLs//NrS5KMmVjqlsnEZdsMnybSnY0KcHl4l/b6B2QmMc6sHthhI0qqWsxaD2k= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a17:90b:224d:: with SMTP id hk13mr751201pjb.183.1644822086476; Sun, 13 Feb 2022 23:01:26 -0800 (PST) Date: Sun, 13 Feb 2022 22:57:41 -0800 In-Reply-To: <20220214065746.1230608-1-reijiw@google.com> Message-Id: <20220214065746.1230608-23-reijiw@google.com> Mime-Version: 1.0 References: <20220214065746.1230608-1-reijiw@google.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH v5 22/27] KVM: arm64: Trap disabled features of ID_AA64PFR1_EL1 From: Reiji Watanabe To: Marc Zyngier , kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Will Deacon , Andrew Jones , Fuad Tabba , Peng Liang , Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220213_230127_838918_E01645A3 X-CRM114-Status: GOOD ( 12.17 ) 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 feature_config_ctrl for MTE, which is indicated in ID_AA64PFR1_EL1, to program configuration register to trap the guest's using the feature when it is not exposed to the guest. Signed-off-by: Reiji Watanabe --- arch/arm64/kvm/sys_regs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 72b7cfaef41e..a3d22f7f642b 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -344,6 +344,11 @@ static void feature_amu_trap_activate(struct kvm_vcpu *vcpu) feature_trap_activate(vcpu, VCPU_CPTR_EL2, CPTR_EL2_TAM, 0); } +static void feature_mte_trap_activate(struct kvm_vcpu *vcpu) +{ + feature_trap_activate(vcpu, VCPU_HCR_EL2, HCR_TID5, HCR_DCT | HCR_ATA); +} + /* For ID_AA64PFR0_EL1 */ static struct feature_config_ctrl ftr_ctrl_ras = { .ftr_reg = SYS_ID_AA64PFR0_EL1, @@ -361,6 +366,15 @@ static struct feature_config_ctrl ftr_ctrl_amu = { .trap_activate = feature_amu_trap_activate, }; +/* For ID_AA64PFR1_EL1 */ +static struct feature_config_ctrl ftr_ctrl_mte = { + .ftr_reg = SYS_ID_AA64PFR1_EL1, + .ftr_shift = ID_AA64PFR1_MTE_SHIFT, + .ftr_min = ID_AA64PFR1_MTE_EL0, + .ftr_signed = FTR_UNSIGNED, + .trap_activate = feature_mte_trap_activate, +}; + struct id_reg_info { /* Register ID */ u32 sys_reg; @@ -885,6 +899,10 @@ static struct id_reg_info id_aa64pfr1_el1_info = { .init = init_id_aa64pfr1_el1_info, .validate = validate_id_aa64pfr1_el1, .vcpu_mask = vcpu_mask_id_aa64pfr1_el1, + .trap_features = &(const struct feature_config_ctrl *[]) { + &ftr_ctrl_mte, + NULL, + }, }; static struct id_reg_info id_aa64isar0_el1_info = {