From patchwork Tue Oct 12 04:35:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12551471 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57727C433F5 for ; Tue, 12 Oct 2021 04:57:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 262FE60D42 for ; Tue, 12 Oct 2021 04:57:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 262FE60D42 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=Sl2+JH6o1eweVMoZGHCdRq18Gwq5YUEVbHY/An3/djU=; b=1PMnjoO48BUXUOd37IbDACLUJu 0RuAnVp3E2RY5eYgiL+UTsDYD1UC29CLJ+vV5jCCGhK/uvj3bRU9nNyWqFpnPbZoYWbb3i6F7lWXC 0nwfB5EV9ukt7A0rQzKxkPQ/kzaKP1dlEqdaGjluLS5m/tt2GsXtchlYZsQog5lmevfii4d1VXWYw B6Q3+IHtKtEHqeLB83A10pVX0m6uxqhNNzH91aSthkQgQSnKZ4CxTtTE3YGLCIyasKmbdT/q2tKh7 EXom+pUzeAfpPh7K1PQcE0exNKPMljZ4olL/Tkix4fSlsWXWJCMHkjDUzu7ddpnCQSjSM7Dou83pN 5YAlKvOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ma9oA-00BX9d-2f; Tue, 12 Oct 2021 04:54:35 +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 1ma9X7-00BQam-Me for linux-arm-kernel@lists.infradead.org; Tue, 12 Oct 2021 04:36:59 +0000 Received: by mail-pl1-x64a.google.com with SMTP id l12-20020a170903120c00b0013eb930584fso8380139plh.22 for ; Mon, 11 Oct 2021 21:36:56 -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=eIUhuChkelcONVLGBJ0a2MPEEEhxwwehMuijtFOAuDI=; b=RuE+yIAI83dgKgc0EI81lpKKKdaCzCn8+SfDwPeU8Fln6xA4/deZlxo2DwtD71VRgy cw6TSj8JyRvn5oKLcvmqRuGF7hVSbUVdrEMEKUojpjZyBBQ+tJ1vSUHBrWlg1IuSMZPv R+rpCZeNhqGRUmc+stVB+dTUWZ147p6Jjc9tP2WejjahKq68g464d/gR3s99oJIo6lWp A/jaKj7gVcm9U7Tzh6Orb4tNznNnOji9vtaNMWche+5EZdUD4rHwml9Y4DQ6LY92/e/n yuPPhMOR//Z2EmHt3/Rk9H1biH/MgK7UmW3yEvDk4dlwnyojLI/KFQPcSc40TnGmCYIW ZXcw== 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=eIUhuChkelcONVLGBJ0a2MPEEEhxwwehMuijtFOAuDI=; b=MZieJU7CuTWVrnKr3r1zMOJ2qE7mExhvnjZlXzhdMXtXU/J6L67swwdOwOtRi/gsci 1g/cgBAglLWXv0IjZFNSi7/piGMha7gC3LKOOIX5+RU1bsv18ZLr8kXLgrSIEeozUJMW IuIOgb718G6Whty3fGFcBWn36t+Kb/XzkdxBkl46T4QQYjENN9vG+/280GDzeAwEJysH g7UTiAnJ5X8OvPP6mfepKJqGjhqHYhtQ4x+QDB6e3stsb++smEQHtoIcfN48HIG5DY/O bJ3FjnYzEDx7h3TwGaoHquJFsXUQKNwirwQZo7DWTcS5sZA2Ib0cZPr2pR75CQ3tkCiR zDOg== X-Gm-Message-State: AOAM532iJy5njHNPaibd5sv2j43pIWgCnaBHHIGvisjfdQ2SSpu34z8K 8A6SSQPrxwmZFqEyu9MDIAcE0dpQoGY= X-Google-Smtp-Source: ABdhPJyTEEEJJ8ULSCGnE5RUuiEtmSCACpElVLQCVz7cpGVyLWG6TLcY5A92rMWKWU0CqVfHfvo0h0Ok6PA= X-Received: from reiji-vws.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:15a3]) (user=reijiw job=sendgmr) by 2002:a17:902:6ac4:b0:13f:52e1:8840 with SMTP id i4-20020a1709026ac400b0013f52e18840mr1435432plt.15.1634013416153; Mon, 11 Oct 2021 21:36:56 -0700 (PDT) Date: Mon, 11 Oct 2021 21:35:34 -0700 In-Reply-To: <20211012043535.500493-1-reijiw@google.com> Message-Id: <20211012043535.500493-25-reijiw@google.com> Mime-Version: 1.0 References: <20211012043535.500493-1-reijiw@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [RFC PATCH 24/25] KVM: arm64: Activate trapping of disabled CPU features for the guest 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-20211011_213657_818770_67B6871F X-CRM114-Status: GOOD ( 10.16 ) 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 Call kvm_vcpu_id_regs_trap_activate() at the first KVM_RUN to activate trapping of disabled CPU features. Signed-off-by: Reiji Watanabe --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 691cb6ee0f5c..41f785fdc2e6 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -743,6 +743,7 @@ long kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, struct kvm_arm_copy_mte_tags *copy_tags); int kvm_id_regs_consistency_check(const struct kvm_vcpu *vcpu); +void kvm_vcpu_id_regs_trap_activate(struct kvm_vcpu *vcpu); /* Guest/host FPSIMD coordination helpers */ int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu); diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 38301ddf8372..6b392d7feab7 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -606,6 +606,8 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) if (kvm_id_regs_consistency_check(vcpu)) return -EPERM; + kvm_vcpu_id_regs_trap_activate(vcpu); + return ret; }