Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp454846iog; Wed, 29 Jun 2022 03:49:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vmHMVouNd8bsWlzo2IYoYcraf9HYQv6SNSMmYbJYs+9FlxltJVApltjfiSnKakk//s/5IP X-Received: by 2002:a05:6402:34ce:b0:435:afb0:1d5a with SMTP id w14-20020a05640234ce00b00435afb01d5amr3354052edc.361.1656499749940; Wed, 29 Jun 2022 03:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656499749; cv=none; d=google.com; s=arc-20160816; b=kO1hpr60eDBshdoKfkchyNSJDtpIHRN9Eeh1chwb6Ig1H1ZUVLAi8woA/XQZy4eumk /bB80v80C/PvDktKF9dRG2LJp6kCtUkoWUappdvhpVw9t0rbOjF9p4p0guz22gOlD6cB xnrSHrI4etOwdmhmuNna6pJ96ApCoObA0Cl1PDFDIyshsCfBo4ZmSGA/Adae87MpM1AH UlSKJrolCcKjsdlfxhR3uJKERtjzFDpqUHa6mdNTiyjmeDPLz8bopu6hCG7KjzW2GQbr bItNo3OZpY7Ykqm5axai8V1TP/nUpho+v53oilX/NISB3tXdV0rKoSq9VMQisXSYZrcu uoZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=trw3LNoiFKTtUvjXEV/QGd2ZkU2tmLP2qFOADoks6lE=; b=JoLklw2vPk/kxs1NdUUgLJKqaV5OZV8KLg8OqEuhBUFs0me2cbCqb5XXPl7pX/EpoT Q/BGEzakUjk3NTJ8gHsBJJeRLSsVIpd/TLMMRDFt+Bkm3paGEa6+Liatwny8ZJmEHVvm oeUgcumf/n+VQ2fcFDA5V3dtUryDN2Va8pWoF7ZwKkEfiQE9MgCKOByLU+Wd7ufER6UN 1p33aI7tb7Po98824Fm8rS3cvClVxRa8X0vw31DJoKVhVpTonTwLodvIxceTCbja2Z7c FtJzMnokXKOCp4/+FEYZP910bC+gVXC2eDmIt0Z0ihA2PbDMubkLCDwcDRGgUaHTd1q0 K84w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=M9OWPVf4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb13-20020a1709071c8d00b006f3dae85820si19833721ejc.472.2022.06.29.03.48.43; Wed, 29 Jun 2022 03:49:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=M9OWPVf4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232129AbiF2KYG (ORCPT + 99 others); Wed, 29 Jun 2022 06:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbiF2KYE (ORCPT ); Wed, 29 Jun 2022 06:24:04 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D84E127B0E; Wed, 29 Jun 2022 03:24:03 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 23so14887494pgc.8; Wed, 29 Jun 2022 03:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=trw3LNoiFKTtUvjXEV/QGd2ZkU2tmLP2qFOADoks6lE=; b=M9OWPVf47nuV8h5P3dcKIGBCbEt/qE7nMTjJlxWZpUbV0XCcziQYxQ3qi2lTLQFM8j Jr0rHXzEsFFQqXH19FRNPsYru0tUjypAOKGFWVoH9LMxNiaZNHz3M0dF7EEStnB5TQYl 5diKfYn8sQGP8iULjg1i36LiLFSWWLhVtn3AlpklLwIRT2APk2oQRbKYoIQht9++c2Wt jUeJJCMOc40ZumsfrEVbXq6d9y/E8GpHCkkopzbiqlVPKUZG+FOYUnk4iWL62b+ZR3wg 6k6L5+NRwx9L3cJ57I0H8B8yXikePaOa45phaGhpCXo4LPPd4KmqikLDoS+KbxCCEvub Gg8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=trw3LNoiFKTtUvjXEV/QGd2ZkU2tmLP2qFOADoks6lE=; b=1EH+7Ukv3zYkXPRryQUrSRWAqkZ9X8DgQcYWA/Bdzq4dA4mq6HJWo90atfBqsp6069 nG9SwYuWLG1QWigdGiHAeNBu0AZPwEHfdyYvQSiwh4hg4LsBWaP9cHSnfnVargTGqSdl 6vwQU3CzTeqbapWWm7FXhiKuyxOMFydbMinnAmQJqYG0qLeZfzBHYIspD7g3Up5GDr1/ 0btK6/pFsYRsoQ+yY+nMegBFFkgrQlwZlO6VJ5FaqKRcO3PbADHTtv5Zg14lJdJ1tHcS pjWpxlriMdfmtjKr7j80CzghxcVQRrYRS9yc9osgVsEiu7vFTjtqLHw5+rg+aV16o2ZS Ro2A== X-Gm-Message-State: AJIora/W3QESEfh7L/55Hlbe37ZjJhZRXCMuSARa/GKXFAElCPZTKNrw nbVSFKuGc1TRyhkRVJ6LaTXP2O6BDAc= X-Received: by 2002:a63:be41:0:b0:40c:b4a8:dee9 with SMTP id g1-20020a63be41000000b0040cb4a8dee9mr2366496pgo.107.1656498243314; Wed, 29 Jun 2022 03:24:03 -0700 (PDT) Received: from localhost (fmdmzpr02-ext.fm.intel.com. [192.55.54.37]) by smtp.gmail.com with ESMTPSA id c5-20020a17090abf0500b001ef0fed7046sm1705903pjs.15.2022.06.29.03.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 03:24:02 -0700 (PDT) Date: Wed, 29 Jun 2022 03:24:01 -0700 From: Isaku Yamahata To: Sagi Shahar Cc: "Yamahata, Isaku" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , Erdem Aktas , Sean Christopherson Subject: Re: [RFC PATCH v6 095/104] KVM: TDX: Handle TDX PV rdmsr/wrmsr hypercall Message-ID: <20220629102401.GC882746@ls.amr.corp.intel.com> References: <9a45667060dd2f8634bf1ecba23b89567c7e46e7.1651774251.git.isaku.yamahata@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 10, 2022 at 02:04:49PM -0700, Sagi Shahar wrote: > On Thu, May 5, 2022 at 11:16 AM wrote: > > > > From: Isaku Yamahata > > > > Wire up TDX PV rdmsr/wrmsr hypercall to the KVM backend function. > > > > Signed-off-by: Isaku Yamahata > > Reviewed-by: Paolo Bonzini > > --- > > arch/x86/kvm/vmx/tdx.c | 37 +++++++++++++++++++++++++++++++++++++ > > 1 file changed, 37 insertions(+) > > > > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c > > index f46825843a8b..1518a8c310d6 100644 > > --- a/arch/x86/kvm/vmx/tdx.c > > +++ b/arch/x86/kvm/vmx/tdx.c > > @@ -1169,6 +1169,39 @@ static int tdx_emulate_mmio(struct kvm_vcpu *vcpu) > > return 1; > > } > > > > +static int tdx_emulate_rdmsr(struct kvm_vcpu *vcpu) > > +{ > > + u32 index = tdvmcall_a0_read(vcpu); > > + u64 data; > > + > > + if (kvm_get_msr(vcpu, index, &data)) { > > kvm_get_msr and kvm_set_msr used to check the MSR permissions using > kvm_msr_allowed but that behaviour changed in "KVM: x86: Only do MSR > filtering when access MSR by rdmsr/wrmsr". > > Now kvm_get_msr and kvm_set_msr skip these checks and will allow > access regardless of the permissions in the msr_filter. > > These should be changed to kvm_get_msr_with_filter and > kvm_set_msr_with_filter or something similar that checks permissions > for MSR access. Thanks for pointing it out. I fixed it as adding kvm_msr_allowed() -- Isaku Yamahata