From: "Jürgen Groß" <jgross@suse.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Kevin Tian" <kevin.tian@intel.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>, "Wei Liu" <wl@xen.org>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Jun Nakajima" <jun.nakajima@intel.com>,
xen-devel@lists.xenproject.org,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v6 09/12] xen: add runtime parameter access support to hypfs
Date: Fri, 6 Mar 2020 09:47:39 +0100 [thread overview]
Message-ID: <0b6e7f36-786c-f788-0c13-7e0ed41d77df@suse.com> (raw)
In-Reply-To: <a593f09f-1e79-8b87-7399-0c03161a5ad6@suse.com>
[-- Attachment #1: Type: text/plain, Size: 5217 bytes --]
On 06.03.20 09:20, Jan Beulich wrote:
> On 06.03.2020 07:42, Jürgen Groß wrote:
>> On 05.03.20 09:26, Jan Beulich wrote:
>>> On 05.03.2020 07:01, Jürgen Groß wrote:
>>>> On 04.03.20 17:56, Jan Beulich wrote:
>>>>> On 04.03.2020 17:31, Jürgen Groß wrote:
>>>>>> On 04.03.20 16:19, Jan Beulich wrote:
>>>>>>> On 04.03.2020 16:07, Jürgen Groß wrote:
>>>>>>>> On 04.03.20 12:32, Jan Beulich wrote:
>>>>>>>>> On 26.02.2020 13:47, Juergen Gross wrote:
>>>>>>>>>> +static void update_ept_param_append(const char *str, int val)
>>>>>>>>>> +{
>>>>>>>>>> + char *pos = opt_ept_setting + strlen(opt_ept_setting);
>>>>>>>>>> +
>>>>>>>>>> + snprintf(pos, sizeof(opt_ept_setting) - (pos - opt_ept_setting),
>>>>>>>>>> + ",%s=%d", str, val);
>>>>>>>>>> +}
>>>>>>>>>> +
>>>>>>>>>> +static void update_ept_param(void)
>>>>>>>>>> +{
>>>>>>>>>> + snprintf(opt_ept_setting, sizeof(opt_ept_setting), "pml=%d", opt_ept_pml);
>>>>>>>>>> + if ( opt_ept_ad >= 0 )
>>>>>>>>>> + update_ept_param_append("ad", opt_ept_ad);
>>>>>>>>>
>>>>>>>>> This won't correctly reflect reality: If you look at
>>>>>>>>> vmx_init_vmcs_config(), even a negative value means "true" here,
>>>>>>>>> unless on a specific Atom model. I think init_ept_param() wants
>>>>>>>>> to have that erratum workaround logic moved there, such that
>>>>>>>>> you can then assme the value to be non-negative here.
>>>>>>>>
>>>>>>>> But isn't not mentioning it in the -1 case correct? -1 means: do the
>>>>>>>> correct thing on the current hardware.
>>>>>>>
>>>>>>> Well, I think the output here should represent effective settings,
>>>>>>
>>>>>> The minimum requirement is to reflect the effective parameters, like
>>>>>> cmdline is doing for boot-time only parameters. With runtime parameters
>>>>>> we had no way of telling what was set, and this is now possible.
>>>>>>
>>>>>>> and a sub-item should be suppressed only if a setting has no effect
>>>>>>> at all in the current setup, like ...
>>>>>>>
>>>>>>>>>> + if ( opt_ept_exec_sp >= 0 )
>>>>>>>>>> + update_ept_param_append("exec-sp", opt_ept_exec_sp);
>>>>>>>>>
>>>>>>>>> I agree for this one - if the value is still -1, it has neither
>>>>>>>>> been set nor is its value of any interest.
>>>>>>>
>>>>>>> ... here.
>>>>>>
>>>>>> I think we should not mix up specified parameters and effective
>>>>>> settings. In case an effective setting is of common interest it should
>>>>>> be reported via a specific node (like e.g. specific mitigation settings
>>>>>> where the cmdline is not providing enough details).
>>>>>
>>>>> But then a boolean option that wasn't specified on the command line
>>>>> should produce no output at all. And hence we'd need a way to tell
>>>>> whether an option was set from command line for _all_ of them. I
>>>>> don't think this would be very helpful.
>>>>
>>>> I disagree here.
>>>>
>>>> This is important only for cases where the hypervisor treats the
>>>> parameter as a tristate: true/false/unspecified. In all cases where
>>>> the bool value is really true or false it can be reported as such.
>>>
>>> The problem I'm having with this is the resulting inconsistency:
>>> When we write the variable with 0 or 1 in case we find it to be
>>> -1 after command line parsing, the externally visible effect will
>>> be different from the case where we leave it to be -1 yet still
>>> treat it as (pseudo-)boolean. This, however, is an implementation
>>> detail, while imo the hypfs presentation should not depend on
>>> such implementation details.
>>>
>>>> Reporting 0/1 for e.g. "ad" if opt_ept_ad==-1 would add a latent problem
>>>> if any other action would be derived from the parameter variable being
>>>> -1.
>>>>
>>>> So either opt_ept_ad should be modified to change it to 0/1 instead of
>>>> only setting the VCMS flag,
>>>
>>> That's what I did suggest.
>>>
>>>> or the logic should be kept as is in this
>>>> patch. IMO changing the setting of opt_ept_ad should be done in another
>>>> patch if this is really wanted.
>>>
>>> And of course I don't mind at all doing so in a prereq patch.
>>> It's just that the patch here provides a good place _where_ to
>>> actually do such an adjustment.
>>
>> I was thinking of something like this:
>>
>> --- a/xen/arch/x86/hvm/vmx/vmcs.c
>> +++ b/xen/arch/x86/hvm/vmx/vmcs.c
>> @@ -313,12 +313,12 @@ static int vmx_init_vmcs_config(void)
>> {
>> rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, _vmx_ept_vpid_cap);
>>
>> + if ( /* Work around Erratum AVR41 on Avoton processors. */
>> + boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x4d &&
>> + opt_ept_ad < 0 )
>> + opt_ept_ad = 0;
>> if ( !opt_ept_ad )
>> _vmx_ept_vpid_cap &= ~VMX_EPT_AD_BIT;
>> - else if ( /* Work around Erratum AVR41 on Avoton processors. */
>> - boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x4d &&
>> - opt_ept_ad < 0 )
>> - _vmx_ept_vpid_cap &= ~VMX_EPT_AD_BIT;
>>
>> /*
>> * Additional sanity checking before using EPT:
>
> And I was specifically hoping to avoid doing this in a non-__init
> function.
Should be fairly easy (see attached patch).
Juergen
[-- Attachment #2: 0001-xen-vmx-let-opt_ept_ad-always-reflect-the-current-se.patch --]
[-- Type: text/x-patch, Size: 3623 bytes --]
From 32f307522c2044130bb8ed66189efc411c540103 Mon Sep 17 00:00:00 2001
From: Juergen Gross <jgross@suse.com>
Date: Fri, 6 Mar 2020 07:30:36 +0100
Subject: [PATCH] xen/vmx: let opt_ept_ad always reflect the current setting
In case opt_ept_ad has not been set explicitly by the user via command
line or runtime parameter, it is treated as "no" on Avoton cpus.
Change that handling by setting opt_ept_ad to 0 for this cpu type
explicitly if no user value has been set.
By putting this into the (renamed) boot time initialization of vmcs.c
_vmx_cpu_up() can be made static.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
xen/arch/x86/hvm/vmx/vmcs.c | 22 +++++++++++++++-------
xen/arch/x86/hvm/vmx/vmx.c | 4 +---
xen/include/asm-x86/hvm/vmx/vmcs.h | 3 +--
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 4c23645454..24f2bd6e43 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -315,10 +315,6 @@ static int vmx_init_vmcs_config(void)
if ( !opt_ept_ad )
_vmx_ept_vpid_cap &= ~VMX_EPT_AD_BIT;
- else if ( /* Work around Erratum AVR41 on Avoton processors. */
- boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x4d &&
- opt_ept_ad < 0 )
- _vmx_ept_vpid_cap &= ~VMX_EPT_AD_BIT;
/*
* Additional sanity checking before using EPT:
@@ -652,7 +648,7 @@ void vmx_cpu_dead(unsigned int cpu)
vmx_pi_desc_fixup(cpu);
}
-int _vmx_cpu_up(bool bsp)
+static int _vmx_cpu_up(bool bsp)
{
u32 eax, edx;
int rc, bios_locked, cpu = smp_processor_id();
@@ -2108,9 +2104,21 @@ static void vmcs_dump(unsigned char ch)
printk("**************************************\n");
}
-void __init setup_vmcs_dump(void)
+int __init vmx_vmcs_init(void)
{
- register_keyhandler('v', vmcs_dump, "dump VT-x VMCSs", 1);
+ int ret;
+
+ if ( opt_ept_ad < 0 )
+ /* Work around Erratum AVR41 on Avoton processors. */
+ opt_ept_ad = (boot_cpu_data.x86 == 6 &&
+ boot_cpu_data.x86_model == 0x4d) ? 0 : 1;
+
+ ret = _vmx_cpu_up(true);
+
+ if ( !ret )
+ register_keyhandler('v', vmcs_dump, "dump VT-x VMCSs", 1);
+
+ return ret;
}
static void __init __maybe_unused build_assertions(void)
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index d265ed46ad..d0ad2ed879 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2478,7 +2478,7 @@ const struct hvm_function_table * __init start_vmx(void)
{
set_in_cr4(X86_CR4_VMXE);
- if ( _vmx_cpu_up(true) )
+ if ( vmx_vmcs_init() )
{
printk("VMX: failed to initialise.\n");
return NULL;
@@ -2549,8 +2549,6 @@ const struct hvm_function_table * __init start_vmx(void)
vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
}
- setup_vmcs_dump();
-
lbr_tsx_fixup_check();
bdf93_fixup_check();
diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h
index be4661a929..b346a132e2 100644
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h
@@ -21,11 +21,10 @@
#include <asm/hvm/io.h>
extern void vmcs_dump_vcpu(struct vcpu *v);
-extern void setup_vmcs_dump(void);
+extern int vmx_vmcs_init(void);
extern int vmx_cpu_up_prepare(unsigned int cpu);
extern void vmx_cpu_dead(unsigned int cpu);
extern int vmx_cpu_up(void);
-extern int _vmx_cpu_up(bool bsp);
extern void vmx_cpu_down(void);
struct vmcs_struct {
--
2.16.4
[-- Attachment #3: Type: text/plain, Size: 157 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-03-06 8:48 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 12:46 [Xen-devel] [PATCH v6 00/12] Add hypervisor sysfs-like support Juergen Gross
2020-02-26 12:46 ` [Xen-devel] [PATCH v6 01/12] xen: allow only sizeof(bool) variables for boolean_param() Juergen Gross
2020-03-03 16:40 ` Jan Beulich
2020-03-09 11:43 ` Julien Grall
2020-03-09 11:55 ` Jan Beulich
2020-03-09 13:01 ` Jürgen Groß
2020-03-09 13:06 ` Jan Beulich
2020-03-09 14:06 ` Jürgen Groß
2020-02-26 12:46 ` [Xen-devel] [PATCH v6 02/12] xen: add a generic way to include binary files as variables Juergen Gross
2020-02-26 12:46 ` [Xen-devel] [PATCH v6 03/12] docs: add feature document for Xen hypervisor sysfs-like support Juergen Gross
2020-03-09 11:48 ` Julien Grall
2020-03-25 14:05 ` Jürgen Groß
2020-02-26 12:46 ` [Xen-devel] [PATCH v6 04/12] xen: add basic hypervisor filesystem support Juergen Gross
2020-03-03 16:59 ` Jan Beulich
2020-03-04 12:00 ` Jürgen Groß
2020-03-04 13:03 ` Jan Beulich
2020-03-04 14:39 ` Jürgen Groß
2020-03-04 15:07 ` Jan Beulich
2020-03-04 15:14 ` Jürgen Groß
2020-03-04 15:21 ` Jan Beulich
2020-03-06 6:06 ` Jürgen Groß
2020-03-06 8:19 ` Jan Beulich
2020-02-26 12:46 ` [Xen-devel] [PATCH v6 05/12] libs: add libxenhypfs Juergen Gross
2020-02-26 12:46 ` [Xen-devel] [PATCH v6 06/12] tools: add xenfs tool Juergen Gross
2020-02-26 12:47 ` [Xen-devel] [PATCH v6 07/12] xen: provide version information in hypfs Juergen Gross
2020-02-26 12:47 ` [Xen-devel] [PATCH v6 08/12] xen: add /buildinfo/config entry to hypervisor filesystem Juergen Gross
2020-03-04 10:49 ` Jan Beulich
2020-03-04 12:06 ` Jürgen Groß
2020-03-04 13:04 ` Jan Beulich
2020-02-26 12:47 ` [Xen-devel] [PATCH v6 09/12] xen: add runtime parameter access support to hypfs Juergen Gross
2020-03-04 11:32 ` Jan Beulich
2020-03-04 15:07 ` Jürgen Groß
2020-03-04 15:19 ` Jan Beulich
2020-03-04 16:31 ` Jürgen Groß
2020-03-04 16:56 ` Jan Beulich
2020-03-05 6:01 ` Jürgen Groß
2020-03-05 8:26 ` Jan Beulich
2020-03-06 6:42 ` Jürgen Groß
2020-03-06 8:20 ` Jan Beulich
2020-03-06 8:47 ` Jürgen Groß [this message]
2020-03-06 9:04 ` Jan Beulich
2020-03-06 9:20 ` Jürgen Groß
2020-03-06 9:22 ` Jan Beulich
2020-03-06 9:27 ` Jürgen Groß
2020-03-23 10:38 ` Julien Grall
2020-02-26 12:47 ` [Xen-devel] [PATCH v6 10/12] tools/libxl: use libxenhypfs for setting xen runtime parameters Juergen Gross
2020-02-26 12:47 ` [Xen-devel] [PATCH v6 11/12] tools/libxc: remove xc_set_parameters() Juergen Gross
2020-02-26 12:47 ` [Xen-devel] [PATCH v6 12/12] xen: remove XEN_SYSCTL_set_parameter support Juergen Gross
2020-03-04 11:45 ` Jan Beulich
2020-03-04 14:40 ` Jürgen Groß
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b6e7f36-786c-f788-0c13-7e0ed41d77df@suse.com \
--to=jgross@suse.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).