From patchwork Tue Apr 19 06:55:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12817536 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 CD9D7C433F5 for ; Tue, 19 Apr 2022 07:18:46 +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=7sw8TwWh9J6bR1+v2QCYk+NKu+d97kWQ5z58sCLAeMI=; b=YX7nDa+l8vRZIxTxJ+SNPCwSgM MjglXLxnDS/poK8WWvHXw9fjW5Xe2IXHfT15fo0g1lRaray/XNNlkY8uHAqkEgg1yT06pSsBEW9w0 012QUh5Kk9f7tlSx5sZRTQzt5ZRPfE8QrEjLDYrsnypN4a7p+iBQhE6RIEBeP3gHULuPlVytTXchB /qrSukcT+gD0lh0fCxtq57JECkK6FuqxKeyZdakHtkm23U9U/zN6EjSApselcnMArfyC/NixGORzV iij0bU6ziKhwoSBOQw6LevQobOfYGgegn1/VXOWwyro2n1mOKb8ahAwb6Hg+gsf3dI1/Jxqx30gAE EpUwcwNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngi6t-001us3-A0; Tue, 19 Apr 2022 07:17:16 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngho9-001niF-1E for linux-arm-kernel@lists.infradead.org; Tue, 19 Apr 2022 06:57:54 +0000 Received: by mail-pj1-x104a.google.com with SMTP id r15-20020a17090a4dcf00b001cb7ea0b0bdso1046969pjl.1 for ; Mon, 18 Apr 2022 23:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=11aokqGJX88zjYco/n0ZubDfebB61Zyyzannu13jVUU=; b=KGkjLi1nc3eXEFUtTXU9CrYnMm5oE1zb1JyJJ5B7usLojN2sR4jMVUo4tdKam79pra OVVDdODyp0s3nG2ZJo8xAbdCAAdfINz0DvmkTYgcDoJPyjrFRzEMbWEhr3S17VgMcZzD nM3JFqyi9usgPOH9nh6yHH3K9EhDv+VHrkC9rBBlvfOu2MszL4Hs+DDC22Em2O6ZKNxl 5AeVCwzg50biwYCMn8UmZJ1+S+oPSbmtdfJ4IcoWZFIIysV0uXT2l+BZurMipMNhaudj 6H2envE5Qpe3dAMXTa3BuELSOXXVwTJH4rpI5ANhGr44gOvC13Npdua3r4pKU8cmUmQJ 8T2w== 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=11aokqGJX88zjYco/n0ZubDfebB61Zyyzannu13jVUU=; b=Wm4DG29dpdIkZ4j+z1EysvWuy3O7AR7LRsxF/ou1g8f94pmiXydf/ukgEI9H0zOnq0 S2fthQt5kUYveVDsnj/4SuJTFl3nliDTEO73SVkig9My/ck2tUY/qjDS/C8g2flBkH1P 6X/pHp4zadQUbXf+5PdVDpDqPF0WxLZeRd/+19O6dg0JcnU88zInEt7TTWmDiLyDrga7 7G8tL3RtqS0FUblUVfSduVQnagYQ0XZzDX9CbjbXK/0J8XdUwO5RuXG3rnxiGfkCfslo bH5I9LlCu56HgAeJkaH7swXORd8DV7Ev2/NO+OTTOHIRPFIql/Xx9MrQGf0WZAFe2poO 8pBA== X-Gm-Message-State: AOAM533Oznr34s+tS+k4kF4X+/C9Ul9wlyZNdN5Ia6CWfEL5RGL6gMPS 26q+3O75EbaFbESBPapBwEFgnZnTQj4= X-Google-Smtp-Source: ABdhPJxTNMo4W/KfFAQ3BdCNc/v2d2neST1XZcUkDoxRPAerssfdLoDu8lxxEk0L7o4yB7dQku5s92k37v0= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a17:902:c792:b0:158:ba0c:cf6d with SMTP id w18-20020a170902c79200b00158ba0ccf6dmr14555949pla.131.1650351471625; Mon, 18 Apr 2022 23:57:51 -0700 (PDT) Date: Mon, 18 Apr 2022 23:55:34 -0700 In-Reply-To: <20220419065544.3616948-1-reijiw@google.com> Message-Id: <20220419065544.3616948-29-reijiw@google.com> Mime-Version: 1.0 References: <20220419065544.3616948-1-reijiw@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [PATCH v7 28/38] 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-20220418_235753_121718_956F2E03 X-CRM114-Status: GOOD ( 11.97 ) 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 fecd54a58d34..10f366957ce9 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -360,6 +360,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, @@ -377,6 +382,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, +}; + #define __FTR_BITS(ftr_sign, ftr_type, bit_pos, safe) { \ .sign = ftr_sign, \ .type = ftr_type, \ @@ -4312,6 +4326,10 @@ static struct id_reg_desc id_aa64pfr1_el1_desc = { .init = init_id_aa64pfr1_el1_desc, .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_desc id_aa64isar0_el1_desc = {