Received: by 10.223.185.116 with SMTP id b49csp5843841wrg; Tue, 27 Feb 2018 22:55:45 -0800 (PST) X-Google-Smtp-Source: AH8x225P1X9oXcJBGQNn1ROEJHJPHwgs5d34A14bvNknSTdeQnFfIJxUYDSJ38198ITzOBM/wBTl X-Received: by 2002:a17:902:8488:: with SMTP id c8-v6mr16995397plo.155.1519800945647; Tue, 27 Feb 2018 22:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519800945; cv=none; d=google.com; s=arc-20160816; b=gf7Q9wzwHC6rRrvm097ixscCbcFFPACT8eEV+hiIPHi1jULOz7HnNS/tZUT1QlclKN IxezJuRe+ISBvSsf/7PHDKV1T8Bg575rlDGHduY2fmTdL/nXnbD2xjVL30yNhcZ0lrq6 QOR0HUxSeN7LaZLyo5lcHXj0THlJKHFIjPLxb3kTKUYyhWyzHCzz6RCRv7yH9AMzgaqn NbQT84RWqq0hV9C+DNS91vlnO4kADbQadNN7UcUyDq3OVrLk5FWHGRsCQyRbypYqE0jb 9NzB3ONV0/PgVNX1YnPGf/yodEnM1/OoBh1kt++LlE6WqJtDIWVsWrWcyh9tpuwYz79W EZ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=2sXSyjOQc0QLlM5kl+UgYmjU6+lSVO43bTRnos7gNuQ=; b=hJpzsglN1aXmGy4wplm5e5lyuUmbL/xvAxGnx3S5S/OuTeXOhlj3fI6NlnTWuI1VY8 2lS3kSDJ3UlRFa/Qk8Yuz8N8k/qHpIy0m01Ds9MK1/43v50BXafkzqcszSMLpoPbrfBl M4nNKSdr9TINMaXkIZx+MNXtIGB8Ez4OQSD1E7lynWEo9Z7wjWCc7WmrZa5pNDcw0cDs B7OkJIEy4x1Do8mo6BfTD0LXFuo+10z11BS/ARfcktXATi5xnVUElwXbQukERO0/MN/l HH6t6B5ZDZCc8Qk61AJuJosXNnBT7CsGOKzk/jgnC9ghM64cJQVh2rwt9jJQQYI7MhFM Z8IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VmnZA4cZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg3-v6si800851plb.28.2018.02.27.22.55.30; Tue, 27 Feb 2018 22:55:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VmnZA4cZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbeB1Gyt (ORCPT + 99 others); Wed, 28 Feb 2018 01:54:49 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53326 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbeB1Gyr (ORCPT ); Wed, 28 Feb 2018 01:54:47 -0500 Received: by mail-wm0-f68.google.com with SMTP id t74so2863037wme.3; Tue, 27 Feb 2018 22:54:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=2sXSyjOQc0QLlM5kl+UgYmjU6+lSVO43bTRnos7gNuQ=; b=VmnZA4cZozPPlsciq69jGQvGzZoXOEku0ymAAeXtl5gyXxtnfXfenDGX/xlMgpPGx9 zNjJQV9uzWFSCAKstRw/2BSUjj2lx8aemGvmz70Yt6ilz9gMDLsQecWYve1qN+LRwIJY BRR68i/JKo9OXJrETyNV6L7h593xykZZB7uBT7xB8B3Mpna9r+60XanF5mDoiC9dooQQ TsTPUCNfiL+RoxcUn+BOsQVEsfi+rJnDWFisCLFiD+Jh7lvZZ7x+S5uB3Ex7Jf+MKy6o 2u86WvI9PtciGX/j0+OVcy4Ylh9u0AE19YK81s7h1O9hEs+Qi0DFDbqznToh3t4qH9d8 P9vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2sXSyjOQc0QLlM5kl+UgYmjU6+lSVO43bTRnos7gNuQ=; b=lG0x1sxKuXBo77p8Mc3K18FABy5fMyJiIGDErDVGQgqRuxaoLqUxrSUAZwnELMcFny jBysK+igjlSUrMAWXRfbaIh56Y0tlUGTDK0oE2IW3p95UEbFgmOZVijwbDxcCSguPUf6 rj6EiNIOMbCZBs2bzyrQ1JAfYa/t+L6xx9q92MTBg1jUb5Z3sv2HvJ8jaddX+dehZuxQ WYIjtEYiNA/l5sZ4FUKcqnWvrd0Eq4Um73nvW+NOxnKF8pvKpQAMh2ln3zvOmDlNBX3D +u4Hx8dnUZfYi8stvq+kK9DqLh4PihFUtiAmE8EB8vbUz3UdrV6fKo3hX3pPtbkJoVJ1 zlPw== X-Gm-Message-State: APf1xPCwUz09168IEVYohZuhXK7eoCOpVk1aQSXYFCS2D5xx3ejWyZ2e TdqfRumWUccCtYh5Bga5LZM= X-Received: by 10.80.141.77 with SMTP id t13mr21933783edt.238.1519800886133; Tue, 27 Feb 2018 22:54:46 -0800 (PST) Received: from [192.168.10.150] (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.googlemail.com with ESMTPSA id j55sm1651673ede.14.2018.02.27.22.54.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 22:54:45 -0800 (PST) Subject: Re: [PATCH RESEND v5 1/2] KVM: X86: Introduce kvm_get_msr_feature() To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Liran Alon , Nadav Amit , Borislav Petkov , Tom Lendacky References: <1519797811-4560-1-git-send-email-wanpengli@tencent.com> From: Paolo Bonzini Message-ID: <38179d9e-537a-f002-a98d-5b48b10a4ea9@redhat.com> Date: Wed, 28 Feb 2018 07:54:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519797811-4560-1-git-send-email-wanpengli@tencent.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/02/2018 07:03, Wanpeng Li wrote: > From: Wanpeng Li > > Introduce kvm_get_msr_feature() to handle the msrs which are supported > by different vendors and sharing the same emulation logic. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Liran Alon > Cc: Nadav Amit > Cc: Borislav Petkov > Cc: Tom Lendacky > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/x86.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index d4985a9..efc8554 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -1062,13 +1062,25 @@ static u32 msr_based_features[] = { > > static unsigned int num_msr_based_features; > > +static int kvm_get_msr_feature(struct kvm_msr_entry *msr) > +{ > + switch (msr->index) { > + default: > + if (kvm_x86_ops->get_msr_feature(msr)) > + return 1; > + } > + return 0; > +} > + > static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data) > { > struct kvm_msr_entry msr; > + int r; > > msr.index = index; > - if (kvm_x86_ops->get_msr_feature(&msr)) > - return 1; > + r = kvm_get_msr_feature(&msr); > + if (r) > + return r; > > *data = msr.data; > > @@ -4538,7 +4550,7 @@ static void kvm_init_msr_list(void) > struct kvm_msr_entry msr; > > msr.index = msr_based_features[i]; > - if (kvm_x86_ops->get_msr_feature(&msr)) > + if (kvm_get_msr_feature(&msr)) > continue; > > if (j < i) > Reviewed-by: Paolo Bonzini