* [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore
@ 2021-07-02 19:03 Andrew Cooper
2021-07-05 7:35 ` Olaf Hering
2021-07-05 8:01 ` Jan Beulich
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2021-07-02 19:03 UTC (permalink / raw)
To: Xen-devel
Cc: Andrew Cooper, Jan Beulich, Roger Pau Monné,
Wei Liu, Ian Jackson, Olaf Hering
0x1c is lower than any value which will actually be observed in
p->extd.max_leaf, but higher than the logical 9 leaves worth of extended data
on Intel systems, causing x86_cpuid_copy_to_buffer() to fail with -ENOBUFS.
Correct the calculation.
The problem was first noticed in c/s 34990446ca9 "libxl: don't ignore the
return value from xc_cpuid_apply_policy" but introduced earlier.
Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy")
Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Ian Jackson <iwj@xenproject.org>
CC: Olaf Hering <olaf@aepfle.de>
Olaf - as I've changed the fix, I haven't included your T-by tag, but I'm
confident that this will suitably address the issue.
---
tools/libs/guest/xg_cpuid_x86.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index e01d657e0394..0c9c4fefc1ef 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -513,7 +513,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore,
/* Clamp maximum leaves to the ones supported on 4.12. */
p->basic.max_leaf = min(p->basic.max_leaf, 0xdu);
p->feat.max_subleaf = 0;
- p->extd.max_leaf = min(p->extd.max_leaf, 0x1cu);
+ p->extd.max_leaf = min(p->extd.max_leaf, 0x8000001c);
}
if ( featureset )
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore
2021-07-02 19:03 [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore Andrew Cooper
@ 2021-07-05 7:35 ` Olaf Hering
2021-07-05 10:26 ` Andrew Cooper
2021-07-05 8:01 ` Jan Beulich
1 sibling, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2021-07-05 7:35 UTC (permalink / raw)
To: Andrew Cooper
Cc: Xen-devel, Jan Beulich, Roger Pau Monné, Wei Liu, Ian Jackson
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
Am Fri, 2 Jul 2021 20:03:34 +0100
schrieb Andrew Cooper <andrew.cooper3@citrix.com>:
> Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy")
I think it fixes 111c8c33a8a18588f3da3c5dbb7f5c63ddb98ce5 ("x86/cpuid: do not expand max leaves on restore"), 34990446ca91 just revealed the bug?
Either way, this new variant is what I had tested last week. But with a trailing "u" for the constant. This detail may not make a difference in practice.
Olaf
[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore
2021-07-02 19:03 [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore Andrew Cooper
2021-07-05 7:35 ` Olaf Hering
@ 2021-07-05 8:01 ` Jan Beulich
1 sibling, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2021-07-05 8:01 UTC (permalink / raw)
To: Andrew Cooper
Cc: Roger Pau Monné, Wei Liu, Ian Jackson, Olaf Hering, Xen-devel
On 02.07.2021 21:03, Andrew Cooper wrote:
> 0x1c is lower than any value which will actually be observed in
> p->extd.max_leaf, but higher than the logical 9 leaves worth of extended data
> on Intel systems, causing x86_cpuid_copy_to_buffer() to fail with -ENOBUFS.
>
> Correct the calculation.
>
> The problem was first noticed in c/s 34990446ca9 "libxl: don't ignore the
> return value from xc_cpuid_apply_policy" but introduced earlier.
>
> Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy")
> Reported-by: Olaf Hering <olaf@aepfle.de>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
perhaps with, as suggested by Olaf, the Fixes: line changed.
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore
2021-07-05 7:35 ` Olaf Hering
@ 2021-07-05 10:26 ` Andrew Cooper
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2021-07-05 10:26 UTC (permalink / raw)
To: Olaf Hering
Cc: Xen-devel, Jan Beulich, Roger Pau Monné, Wei Liu, Ian Jackson
On 05/07/2021 08:35, Olaf Hering wrote:
> Am Fri, 2 Jul 2021 20:03:34 +0100
> schrieb Andrew Cooper <andrew.cooper3@citrix.com>:
>
>> Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy")
> I think it fixes 111c8c33a8a18588f3da3c5dbb7f5c63ddb98ce5 ("x86/cpuid: do not expand max leaves on restore"), 34990446ca91 just revealed the bug?
Urgh... That's what I intended to write here. I'll fix up.
> Either way, this new variant is what I had tested last week. But with a trailing "u" for the constant. This detail may not make a difference in practice.
The trailing u doesn't matter in this case. Furthermore, the way min()
is written, the compiler will object if it were to be wrong.
~Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-05 10:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 19:03 [PATCH] tools/libxenguest: Fix max_extd_leaf calculation for legacy restore Andrew Cooper
2021-07-05 7:35 ` Olaf Hering
2021-07-05 10:26 ` Andrew Cooper
2021-07-05 8:01 ` Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.