Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1277955pxj; Wed, 19 May 2021 02:19:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5LIPdK7oxALKVNuLlCvYSta2DwZyYb3iKoj2FlBg/CEKiBNwDPhAlOCWE31rVwU86ZTcw X-Received: by 2002:a92:ddc6:: with SMTP id d6mr8449179ilr.51.1621415973135; Wed, 19 May 2021 02:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621415973; cv=none; d=google.com; s=arc-20160816; b=abgGclmb0JSqszmeUpS0tk+0NSDGz55J+VXy1joeBjOpc68En4xMkKvajG7gvYVzOr YH4Hsp/CfomydnpFtkayeT136wkfv1oaa8Md9j/UtjruySDBtdolz4GLyEcKl6h7/qEq +bTWOsHp4XMUrXr5FEEJr66uRN0odRh9/npvPsQ5MRu1mSxYgpa6NRWpHhsrmMNjJvSe lG9RY6U19QCH2/wpwSZxaf3uMDGHnyljGvcH3nEFNWXDGBdtA/lWUcBp9+givraEfEgD A7WkMEyuXfkGLvjWCJW7JJmTayFB04qkyPzd7sh47GdipQ1lT8qg5oQ9JYQWsPlZW0hq V9vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rri/ZUWebCAURWUdOsBuRJz+8kSWlPQMsU2NIL6PvoY=; b=vccMsQUqFdgiIxpezLNlkU4WhzTDzbtJtrDckfy7S3XKcjaMnRCuRYr5HUttmQQ0vo 28R2i7RPpkflWYaSHdm2fO5kCUK8/X4yaSf5t+GWQwsW2yv41MB/mkgazuqFg/cdvi6N bxEKMxoTvHmoPpUPxcVXIyEJT4cYFu4Q54z3iY8heDrH0IAqvhrN+ak2ZuJmGpTLTSOy /1AoFSAhTEy/NGM/F74n032IEZAVhJmQedZaLYEVj/hq53hLhKl/SYj5Zvzc2jaXBgG5 h+oUxydoYZq+FEv7TIpcBOQSmYyyNComIoYz5HK8ehUZuJ06MT/KJJDVl6qSinpRQaf9 XkHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FRMPueRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si26046482jas.117.2021.05.19.02.19.20; Wed, 19 May 2021 02:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FRMPueRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344607AbhEQXwC (ORCPT + 99 others); Mon, 17 May 2021 19:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344597AbhEQXwC (ORCPT ); Mon, 17 May 2021 19:52:02 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AA07C061756 for ; Mon, 17 May 2021 16:50:45 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id h7so4074111plt.1 for ; Mon, 17 May 2021 16:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rri/ZUWebCAURWUdOsBuRJz+8kSWlPQMsU2NIL6PvoY=; b=FRMPueRDHgiD5iCfFvtD1s0ilAwmF/bus1HxUHlZsO4yO+Y4hKh9zMq4hstI9wA+yr Ns3pzVTPc0f4VwxvgvaiwPAcXYq5wTkTUnEcw5bxrcDTzD7zqgsfQ1MyutHQP97qzgIo ecMfPUCp/aKHEWCaIUKcnuTuMiSyd6R3+z64HVpN1n8fy5NIjhZggdtG6T8scxbMAYZi nthZhEZrnsytJUDMpXJmY2YmWXPWE0xdmWlUKf3ihhZXJbPVkSjul1zUJqJ6AYuIG5hn nJZdH4r8iXoMsNTCpb1NG+rMOvyOHBJQS8ZZnYa5EKDqIel5WoRnSevz3VAh/ZKh4bi1 5JyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rri/ZUWebCAURWUdOsBuRJz+8kSWlPQMsU2NIL6PvoY=; b=lkiPtV3DQR/cr0wcWy0d9WlzJ26u1yJwxc1x701zZeGM2NVspzuVIu6KaM6lngd27q WlU2H8+AxTEs9hEAZDD57wUwx5WO2BgLWaqQjNstZaJKuzV7zQsNle0LP3dD0VsOzh3Z O1fuH4riQLgBgW0uoNGWG1E0u3/K28mBv3iSVbtSj1y2a7sOyVGSiTU9xfnaqxD2/LEd lwCP6r6CLZyy6m3KWdM2c6RTcoZ8srgyzGMF2zTWoKoq8P3MConr1SJdkSxE9qtY3Xr+ 21y+L8Ekj9wt86doNRBV2qj70nTw6PYyclUgtB78xXjCBJFdYdjFOrAf5dJv6wLy/NYg sYwQ== X-Gm-Message-State: AOAM532ducTHDnzhtL4kH+Sf7Ll3ZjdJNtu/8fq6NNdVCX3thVvk9VK7 aGqtsJ0RVw6uwiSUbNq/69OA7rtUrfc4Kijz+iPN+w== X-Received: by 2002:a17:90a:6f06:: with SMTP id d6mr2110560pjk.216.1621295444570; Mon, 17 May 2021 16:50:44 -0700 (PDT) MIME-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> <20210424004645.3950558-36-seanjc@google.com> In-Reply-To: <20210424004645.3950558-36-seanjc@google.com> From: Reiji Watanabe Date: Mon, 17 May 2021 16:50:28 -0700 Message-ID: Subject: Re: [PATCH 35/43] KVM: x86: Move setting of sregs during vCPU RESET/INIT to common x86 To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -1204,12 +1204,6 @@ static void init_vmcb(struct kvm_vcpu *vcpu) > init_sys_seg(&save->ldtr, SEG_TYPE_LDT); > init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); > > - svm_set_cr0(vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET); > - svm_set_cr4(vcpu, 0); > - svm_set_efer(vcpu, 0); > - kvm_set_rflags(vcpu, X86_EFLAGS_FIXED); > - vcpu->arch.regs[VCPU_REGS_RIP] = 0x0000fff0; Reviewed-by: Reiji Watanabe Those your vCPU RESET/INIT changes look great. I think the change in init_vmcb() basically assumes that the function is called from kvm_vcpu_reset(via svm_vcpu_reset()). Although shutdown_interception() directly calls init_mcb(), I would think the change doesn't matter for the shutdown interception case. IMHO it would be a bit misleading that a function named 'init_vmcb', which is called from other than kvm_vcpu_reset (svm_vcpu_reset()), only partially resets the vmcb (probably just to me though). So, I personally think it would be better if its name or comment can give some more specific information about the assumption. BTW, it looks like two lines of "vcpu->arch.hflags = 0;" can be also removed from the init_vmcb() as well. Thanks, Reiji