Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2683474ybi; Mon, 17 Jun 2019 08:52:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfqJNW4YJxf/dve0Q1rfd4ysJR96Pde35w036usYMQqDsDY4cqIRkkdvumWTrtIIDtGd6Z X-Received: by 2002:a65:6104:: with SMTP id z4mr49769320pgu.319.1560786766535; Mon, 17 Jun 2019 08:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560786766; cv=none; d=google.com; s=arc-20160816; b=NoW78eiyo8gmAI2haqA8BiuP78BXYb+5uLWmZfPaYJ9FHTVJk2SO/0va4OpvvM9o99 e0JP8cn99g5xhRhw4h8gqB4djlqye5iMeIuwyb6H8X0Fl/f0qKtF614npBfW0YqwKgK6 Eo55LS8dxeRmAikjHvTmkZwOB+sy+KBYjJdQBzjZ6BbCQxykOar8wNrNH4PZ/r9HMUAx rqJhjwZL1yUG6oaCc4tHddhoCbzTW0SI4PZKjDJRBkZ+e260HO0cOW4EaNHOeaUdNqYM idr3TpgESZ+FTh3Q3oV0DZz1UM3C4OVWxtTZU3xv1bDqGkg6bIghe0P5DimJ7T1TkpHE AowA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=G8/D7GpjKB+LQz7cw54MBk/Ju7zcyOjhVjqHlX9MY1c=; b=gKtpb9572x1v0Ao/8VwmIvJhA+IRmkUQ4Ofj5D6IZeftQcC4x6tM6ZplDB5WUbZM8a MIYxppLt8UB1zDT0Hq5ctVIZ/M19Vtj1KRjApydDQpEMwyT0IiOtBLqrbAb2SMjA/x39 oaf5DB26VQB9wIZaa1X/+09vlhRFHuJr/aWu4Mg9xBGxmj0ELEIgSjt+G23oJoLWUqJ0 dTC1slK6XTShm+05MOR5h4Z5NFuwgP/M4tZJ625cuv631uGUCOXs2IukYIvOZN3lmTmg xmNTwKHQxgHyhr5wlGyyNGLZxMuTdo38DE85c3crm2A0EbspdwuZXNbK3Qnd5rT5sarY CeHQ== ARC-Authentication-Results: i=1; mx.google.com; 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 33si11121073ply.10.2019.06.17.08.52.30; Mon, 17 Jun 2019 08:52:46 -0700 (PDT) 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; 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 S1728533AbfFQPuq (ORCPT + 99 others); Mon, 17 Jun 2019 11:50:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43146 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbfFQPup (ORCPT ); Mon, 17 Jun 2019 11:50:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C2A3930BC56A; Mon, 17 Jun 2019 15:50:44 +0000 (UTC) Received: from flask (unknown [10.43.2.199]) by smtp.corp.redhat.com (Postfix) with SMTP id E49F2783BF; Mon, 17 Jun 2019 15:50:38 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Mon, 17 Jun 2019 17:50:38 +0200 Date: Mon, 17 Jun 2019 17:50:38 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Xiaoyao Li Cc: Tao Xu , pbonzini@redhat.com, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, sean.j.christopherson@intel.com, fenghua.yu@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, jingqi.liu@intel.com Subject: Re: [PATCH RESEND v3 2/3] KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL Message-ID: <20190617155038.GA13955@flask> References: <20190616095555.20978-1-tao3.xu@intel.com> <20190616095555.20978-3-tao3.xu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 17 Jun 2019 15:50:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2019-06-17 14:31+0800, Xiaoyao Li: > On 6/17/2019 11:32 AM, Xiaoyao Li wrote: > > On 6/16/2019 5:55 PM, Tao Xu wrote: > > > +    if (vmx->msr_ia32_umwait_control != host_umwait_control) > > > +        add_atomic_switch_msr(vmx, MSR_IA32_UMWAIT_CONTROL, > > > +                      vmx->msr_ia32_umwait_control, > > > +                      host_umwait_control, false); > > > > The bit 1 is reserved, at least, we need to do below to ensure not > > modifying the reserved bit: > > > >     guest_val = (vmx->msr_ia32_umwait_control & ~BIT_ULL(1)) | > >             (host_val & BIT_ULL(1)) > > > > I find a better solution to ensure reserved bit 1 not being modified in > vmx_set_msr() as below: > > if((data ^ umwait_control_cached) & BIT_ULL(1)) > return 1; We could just be checking if (data & BIT_ULL(1)) because the guest cannot change its visible reserved value and KVM currently initializes the value to 0. The arch/x86/kernel/cpu/umwait.c series assumes that the reserved bit is 0 (hopefully deliberately) and I would do the same in KVM as it simplifies the logic. (We don't have to even think about migrations between machines with a different reserved value and making it play nicely with possible future implementations of that bit.) Thanks.