2019-07-02 05:19:07

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH v4 0/5] misc fixes to PV extentions code

Hi,

In virtualization environment, PV extensions (drivers, interrupts,
timers, etc) are enabled in the majority of use cases which is the
best option.

However, in some cases (kexec not fully working, benchmarking, etc)
we want to disable PV extensions. We have xen_nopv for that purpose
but only for XEN. For a consistent admin experience a common command
line parameter set across all PV guest implementations is a better
choice.

To achieve this introduce a new 'nopv' parameter which is usable by
most of PV guest implementation. Due to the limitation of some PV
guests(XEN PV, XEN PVH and jailhouse), 'nopv' is ignored for XEN PV
, jailhouse and XEN PVH if booting via Xen-PVH boot entry. If booting
via normal boot entry(like grub2), PVH guest has to panic itself
currently.

While analyzing the PV guest code one bug were found and fixed.
(Patches 1). It can be applied independent of the functional
changes, but is kept in the series as the functional changes
depend on them.

As I see there is an issue with xen_nopv when booting PVH guest, so
I revert 'xen_nopv' in one patch and map it back to 'nopv' in the
following patch. This is the easier way to fix the issue and easy
for review.

I didn't get env to test with jailhouse and Hyperv, the others work
as expected.

v4:
PATCH5 a new patch to add 'xen_nopv' back per Boris

v3:
Remove some unrelated patches from patchset as suggested by Tglx

PATCH1 unchanged
PATCH2 add Reviewed-by
PATCH3 add Reviewed-by
PATCH4 rewrite the patch as Jgross found an issue in old patch,
description is also updated.



v2:
PATCH3 use 'ignore_nopv' for PVH/PV guest as suggested by Jgross.
PATCH5 new added one, specifically for HVM guest

Thanks
Zhenzhong


2019-07-02 05:20:19

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH v4 5/5] xen: Add 'xen_nopv' parameter back for backward compatibility

Map 'xen_nopv' to 'nopv' and mark 'xen_nopv' obsolete in
kernel-parameters.txt

Signed-off-by: Zhenzhong Duan <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
---
Documentation/admin-guide/kernel-parameters.txt | 6 ++++++
arch/x86/xen/enlighten_hvm.c | 7 +++++++
2 files changed, 13 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d5c3dcc..34eb323 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5264,6 +5264,12 @@
improve timer resolution at the expense of processing
more timer interrupts.

+ xen_nopv [X86]
+ Disables the PV optimizations forcing the HVM guest to
+ run as generic HVM guest with no PV drivers.
+ This option is obsoleted by the "nopv" option, which
+ has equivalent effect for XEN platform.
+
nopv= [X86,XEN,KVM,HYPER_V,VMWARE]
Disables the PV optimizations forcing the guest to run
as generic guest with no PV drivers. Currently support
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index 340dff8..5cdd608 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -211,6 +211,13 @@ static void __init xen_hvm_guest_init(void)
#endif
}

+static __init int xen_parse_nopv(char *arg)
+{
+ nopv = true;
+ return 0;
+}
+early_param("xen_nopv", xen_parse_nopv);
+
bool __init xen_hvm_need_lapic(void)
{
if (xen_pv_domain())
--
1.8.3.1

2019-07-02 05:20:26

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH v4 3/5] Revert "xen: Introduce 'xen_nopv' to disable PV extensions for HVM guests."

This reverts commit 8d693b911bb9c57009c24cb1772d205b84c7985c.

Instead we use an unified parameter 'nopv' for all the hypervisor
platforms.

Signed-off-by: Zhenzhong Duan <[email protected]>
Reviewed-by: Juergen Gross <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
---
Documentation/admin-guide/kernel-parameters.txt | 4 ----
arch/x86/xen/enlighten_hvm.c | 12 +-----------
2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 21e08af..d5c3dcc 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5251,10 +5251,6 @@
Disables the ticketlock slowpath using Xen PV
optimizations.

- xen_nopv [X86]
- Disables the PV optimizations forcing the HVM guest to
- run as generic HVM guest with no PV drivers.
-
xen_scrub_pages= [XEN]
Boolean option to control scrubbing pages before giving them back
to Xen, for use by other domains. Can be also changed at runtime
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index ac4943c..7fcb4ea 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -210,18 +210,8 @@ static void __init xen_hvm_guest_init(void)
#endif
}

-static bool xen_nopv;
-static __init int xen_parse_nopv(char *arg)
-{
- xen_nopv = true;
- return 0;
-}
-early_param("xen_nopv", xen_parse_nopv);
-
bool __init xen_hvm_need_lapic(void)
{
- if (xen_nopv)
- return false;
if (xen_pv_domain())
return false;
if (!xen_hvm_domain())
@@ -233,7 +223,7 @@ bool __init xen_hvm_need_lapic(void)

static uint32_t __init xen_platform_hvm(void)
{
- if (xen_pv_domain() || xen_nopv)
+ if (xen_pv_domain())
return 0;

return xen_cpuid_base();
--
1.8.3.1

2019-07-02 18:14:49

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] xen: Add 'xen_nopv' parameter back for backward compatibility

On 7/1/19 1:19 AM, Zhenzhong Duan wrote:
> Map 'xen_nopv' to 'nopv' and mark 'xen_nopv' obsolete in
> kernel-parameters.txt

I am not sure we want patch #3, why not do everything in a single patch?


>
> Signed-off-by: Zhenzhong Duan <[email protected]>
> Cc: Boris Ostrovsky <[email protected]>
> Cc: Juergen Gross <[email protected]>
> Cc: Stefano Stabellini <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> ---
> Documentation/admin-guide/kernel-parameters.txt | 6 ++++++
> arch/x86/xen/enlighten_hvm.c | 7 +++++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index d5c3dcc..34eb323 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -5264,6 +5264,12 @@
> improve timer resolution at the expense of processing
> more timer interrupts.
>
> + xen_nopv [X86]
> + Disables the PV optimizations forcing the HVM guest to
> + run as generic HVM guest with no PV drivers.
> + This option is obsoleted by the "nopv" option, which
> + has equivalent effect for XEN platform.
> +
> nopv= [X86,XEN,KVM,HYPER_V,VMWARE]
> Disables the PV optimizations forcing the guest to run
> as generic guest with no PV drivers. Currently support
> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
> index 340dff8..5cdd608 100644
> --- a/arch/x86/xen/enlighten_hvm.c
> +++ b/arch/x86/xen/enlighten_hvm.c
> @@ -211,6 +211,13 @@ static void __init xen_hvm_guest_init(void)
> #endif
> }
>
> +static __init int xen_parse_nopv(char *arg)
> +{
> + nopv = true;

pr_notice("\"xen_nopv\" is deprecated, please use \"nopv\" instead\n");


-boris

> + return 0;
> +}
> +early_param("xen_nopv", xen_parse_nopv);
> +
> bool __init xen_hvm_need_lapic(void)
> {
> if (xen_pv_domain())

2019-07-03 02:15:52

by Zhenzhong Duan

[permalink] [raw]
Subject: Re: [PATCH v4 5/5] xen: Add 'xen_nopv' parameter back for backward compatibility


On 2019/7/3 2:13, Boris Ostrovsky wrote:
> On 7/1/19 1:19 AM, Zhenzhong Duan wrote:
>> Map 'xen_nopv' to 'nopv' and mark 'xen_nopv' obsolete in
>> kernel-parameters.txt
> I am not sure we want patch #3, why not do everything in a single patch?
>
Thanks for review. I'll fix all those based on your comments.

Zhenzhong