From patchwork Thu Jan 6 04:27:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12705123 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 B55F4C433F5 for ; Thu, 6 Jan 2022 04:43:04 +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=oYJTR34dBthDImmtrKiZvQLfyDFgjik7gZAc9pdFR1k=; b=mKCd7F7IOf++esiSWaBA9U4sAo 7nkayOhrTgh1f4Z7P0LZP7Jt/JLvsKSMADfDpv0h+v93IlXB0aF4BL8Gmwy1RJyrISGzOrE/IJiRa bPQkC3i6bqJxfLNFDlWNC+jSGKZY+JOU3jKCzVKrj0YPMG1ZzwAR5hWTQLKD+uWLlNDNfLEi+JN4U Na4ftoX2BT5aGMEJRqnueEUgr9Ta0nBAn+QkfOrk2FPkJMBvx0wBdM6s045Zfx9j+OFMknMXzpDVY 7KIDPTHKvQkrrWeilFwFEhKZQytRFPKsS4eCUsMy1zIxkAXx9Tmgi8n5XeKdO77y3HXqbMD7JzFgn 2E+RfJog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5KaE-00GWvJ-BC; Thu, 06 Jan 2022 04:41:03 +0000 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5KOe-00GS5D-IR for linux-arm-kernel@lists.infradead.org; Thu, 06 Jan 2022 04:29:06 +0000 Received: by mail-pj1-x1049.google.com with SMTP id e16-20020a17090a119000b001b28f7b2a3bso1002546pja.8 for ; Wed, 05 Jan 2022 20:29:03 -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=qPDa0VEsnhEJbcsFzMR0knGwcI8yYnbYngQzhurSzTI=; b=el0X9Zkgu29y78QxvRRd3e98uRJLbBfd8byXjqGxhRWbWZ5YLstsOUH3SFh+cW/6z/ AVuB1b3VFvR84FyYVgCoeX3qyeSoxYIK9UU5iKlkt+sp13xtyJw7/vR4xGCQhIPlBtXs MlFRDk9JISkEweQpNA55vKistpn9TOflRmiQQHqXIG5WIJlgELrDF6YpN8bIcNyyqp9o F8Z4hvl/K/vZDGgrhVs9PXRe6QB09f/1aeu2jeZsgpsotEIpfkCZX+n9zCAVS0Onnnlq 1vwCqEIl8gWTZ9xflG8USBgiBnrN/MhMk0hlU7CxCS6MR4Od2tIFu1cs91k+Y03JfjoF 28kw== 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=qPDa0VEsnhEJbcsFzMR0knGwcI8yYnbYngQzhurSzTI=; b=o1BTwd9Bpcg5wQiW/sovSTMoXdz1MCpEYC7VsJooNnoq+ffkBFOMjTSXvHOHO98nIt nn/mvXh5E/1uucnIJpdXjDUYftCgEm6BcRUsQt6Ek1KwDLpoCd2rRRbkorxMqJQttMFN B6Q1Bstpy+1U4k0dQL+MNW2OtvG4SVyZtaqCZzQ1JKHDu9iD57ltlyJfLnqvEKGsyiuG /eOVIIm5A9kNKy9a7+bkPoe7ik6hFFYejVhJCs4wdeXVzL2RqLcbF/5TmjxXs8SKrTaZ ebtMztUmq84tHCZnKQfaUYi5MzMMx2ToOi+pPHK6B9eXU09rnpxyFp1XAaAmFfrRvED9 Rjcg== X-Gm-Message-State: AOAM532fJ/jpjcUxNy0hCLwE43uQt5yfoIxJpj5X/lP5ZmZPIUNGzpvM S9ND6mWXOdjW6m04znyzePvLBKrdxig= X-Google-Smtp-Source: ABdhPJw+xFogrAR3QZG8Cbh9A/rmDIhEkalnaXKaSZdJeTa/0vLqoOgvnJWOwy6unb5TL5lq547d52EGcuk= 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:6a88:b0:149:848f:1e8b with SMTP id n8-20020a1709026a8800b00149848f1e8bmr44237005plk.124.1641443343115; Wed, 05 Jan 2022 20:29:03 -0800 (PST) Date: Wed, 5 Jan 2022 20:27:03 -0800 In-Reply-To: <20220106042708.2869332-1-reijiw@google.com> Message-Id: <20220106042708.2869332-22-reijiw@google.com> Mime-Version: 1.0 References: <20220106042708.2869332-1-reijiw@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [RFC PATCH v4 21/26] 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 , 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-20220105_202904_679111_BE4BDD65 X-CRM114-Status: GOOD ( 12.85 ) 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 015d67092d5e..72e745c5a9c2 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 { u32 sys_reg; /* Register ID */ u64 sys_val; /* Sanitized system value */ @@ -847,6 +861,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 = {