Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp518113ybd; Wed, 26 Jun 2019 02:05:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/T0b+P9fDqWJmaz82mfpFu34cluJtAe1oXPoVDB2itl1wtKkeGALhc3pXk+DmDA2rh6Na X-Received: by 2002:a17:902:2be8:: with SMTP id l95mr3883335plb.231.1561539918088; Wed, 26 Jun 2019 02:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561539918; cv=none; d=google.com; s=arc-20160816; b=sze4qppZ+f7ULJ10C9jhTcQrCagqbz1HZBBVtR5MJv6sBt+ky3B+6B8djN9v6lS1Me JDDyFrJjh5KTS05RGIFm69QhUUTDd7sWrFqzaVqi3EIxebT2qvbJrcJ18EGaBgfeJj5d TUngOuBO8nOH8g5XRoNnecW6ExjtYg4/dYQLV3sEE85jfamCMl6K9sABFejSX2LP1cSh 9EMbkoTa9CEMHtW9i/aQKynIS0ibww6P7X2+V8WM1ivwmuoaJ+ICIEqeTVxcvAs/Jq+s csEVDIGq6cRB6sUWLYpyjEaATFnK5kagpb+BQXHtk5A4cwg8vVO1q4+KxVI6vVxuiNGj zB7w== 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; bh=FBPSSg/scb277bQpiBLyTpXD63L+7LRHvHCxvnjdMYg=; b=JBv2Qf+SOcOcdlTQ4QDw2RtPJjHqzaFiImi4Ld3WYzmk/BgEOvb4M5Q47nGGgjfdHj 69K0OpRNrQEr2qc02sp+o6C1xKYcUqK3ySOEZC2yfWqIAZXcO7TtsPvnm9F6G9QusjmF QZei85Pa5AaEiMDfy7mvP+X64GKf91RwVV+7UVI5Z+D/4A0kz0ipb8IBh/vlO/4M5ioO hD/YakJfdJNYlOJK61UBvQHKLQnwCavNyU6vxgjxdjwJ/kPqNSaeu3PCPq89WgqRw0UU +6PkGLf64P1JQ94Da7WrwHx46jSaYW2gTXdeCS4iObuUx5diLHB/ZZ/kJKnmg98Y04K2 cKPw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si2782068plq.92.2019.06.26.02.05.00; Wed, 26 Jun 2019 02:05:18 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbfFZJD2 (ORCPT + 99 others); Wed, 26 Jun 2019 05:03:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:40168 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725379AbfFZJD2 (ORCPT ); Wed, 26 Jun 2019 05:03:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 80357AD09; Wed, 26 Jun 2019 09:03:26 +0000 (UTC) Subject: Re: [PATCH v2 5/7] x86/xen: nopv parameter support for HVM guest To: Zhenzhong Duan , linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@kernel.org, bp@alien8.de, hpa@zytor.com, boris.ostrovsky@oracle.com, sstabellini@kernel.org, peterz@infradead.org, srinivas.eeda@oracle.com, Ingo Molnar , xen-devel@lists.xenproject.org References: <1561377779-28036-1-git-send-email-zhenzhong.duan@oracle.com> <1561377779-28036-6-git-send-email-zhenzhong.duan@oracle.com> <99a28880-c2bf-e328-ee52-afc782af3b74@suse.com> From: Juergen Gross Message-ID: Date: Wed, 26 Jun 2019 11:03:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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 26.06.19 10:56, Zhenzhong Duan wrote: > > On 2019/6/25 20:31, Juergen Gross wrote: >> On 24.06.19 14:02, Zhenzhong Duan wrote: >>> PVH guest needs PV extentions to work, so nopv parameter is ignored >>> for PVH but not for HVM guest. >>> >>> In order for nopv parameter to take effect for HVM guest, we need to >>> distinguish between PVH and HVM guest early in hypervisor detection >>> code. By moving the detection of PVH in xen_platform_hvm(), >>> xen_pvh_domain() could be used for that purpose. >>> >>> Signed-off-by: Zhenzhong Duan >>> Cc: Boris Ostrovsky >>> Cc: Juergen Gross >>> Cc: Stefano Stabellini >>> Cc: Thomas Gleixner >>> Cc: Ingo Molnar >>> Cc: Borislav Petkov >>> Cc: xen-devel@lists.xenproject.org >>> --- >>>   arch/x86/xen/enlighten_hvm.c | 18 ++++++++++++------ >>>   1 file changed, 12 insertions(+), 6 deletions(-) >>> >>> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c >>> index 7fcb4ea..26939e7 100644 >>> --- a/arch/x86/xen/enlighten_hvm.c >>> +++ b/arch/x86/xen/enlighten_hvm.c >>> @@ -25,6 +25,7 @@ >>>   #include "mmu.h" >>>   #include "smp.h" >>>   +extern bool nopv; >>>   static unsigned long shared_info_pfn; >>>     void xen_hvm_init_shared_info(void) >>> @@ -226,20 +227,24 @@ static uint32_t __init xen_platform_hvm(void) >>>       if (xen_pv_domain()) >>>           return 0; >>>   +#ifdef CONFIG_XEN_PVH >>> +    /* Test for PVH domain (PVH boot path taken overrides ACPI >>> flags). */ >>> +    if (!x86_platform.legacy.rtc && x86_platform.legacy.no_vga) >>> +        xen_pvh = true; >> >> Sorry, this won't work, as ACPI tables are scanned only some time later. > Hmm, right. Thanks for point out. >> >> You can test for xen_pvh being true here (for the case where the guest >> has been booted via the Xen-PVH boot entry) and handle that case, but >> the case of a PVH guest started via the normal boot entry (like via >> grub2) and nopv specified is difficult. The only idea I have right now >> would be to use another struct hypervisor_x86 for that case which will >> only be used for Xen HVM/PVH _and_ nopv specified. It should be a copy >> of the bare metal variant, but a special guest_late_init member issuing >> a big fat warning in case PVH is being detected. > > After that warning, I guess PVH will run into hang finally? If it's > true, BUG() is better? > > Adding another hypervisor_x86 is a bit redundant, I think of below change. > > I'll test it tomorrow. But appreciate your suggestion whether it's > feasible. Thanks Yes, this seems to be a viable option. > > --- a/arch/x86/xen/enlighten_hvm.c > +++ b/arch/x86/xen/enlighten_hvm.c > @@ -25,6 +25,7 @@ >  #include "mmu.h" >  #include "smp.h" > > +extern bool nopv; >  static unsigned long shared_info_pfn; > >  void xen_hvm_init_shared_info(void) > @@ -221,11 +222,37 @@ bool __init xen_hvm_need_lapic(void) >         return true; >  } > > +static __init void xen_hvm_nopv_guest_late_init(void) > +{ > +#ifdef CONFIG_XEN_PVH > +       if (x86_platform.legacy.rtc || !x86_platform.legacy.no_vga) > +               return; > + > +       /* PVH detected. */ > +       xen_pvh = true; > + > +       printk(KERN_CRIT "nopv parameter isn't supported in PVH guest\n"); > +       BUG(); > +#endif > +} > + > + >  static uint32_t __init xen_platform_hvm(void) >  { >         if (xen_pv_domain()) >                 return 0; > > +       if (xen_pvh_domain() && nopv) > +       { > +       /* guest booting via the Xen-PVH boot entry goes here */ Mind adjusting indentation of that comment? > +               printk(KERN_INFO "nopv parameter is ignored in PVH > guest\n"); > +       } > +       else if (nopv) > +       { > +       /* guest booting via normal boot entry (like via grub2) goes > here */ Same again? With those corrected and no other changes you can add my: Reviewed-by: Juergen Gross Juergen