ACPI: VM fork detection for RNG
Subsystems (3)
Jason A. Donenfeld
maintainerv5 cover ACPI: VM fork detection for RNG
Hi Rafael & Len,
This patchset is directed toward you two specifically. Patches 1/3 and 3/3 have been through the ringer of review a bit already and do not specifically require your attention, but in v4 we wound up getting hung up on an ACPI API limitation. This v5 fixes that limitation with its 2/3 patch, with a trivial one line fix, which does require your attention.
Patches 1/3 and 3/3 will go through my random.git tree. However, 3/3 actually depends on 2/3 in order to compile without warnings (and be functional at all). Therefore, it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
Please have a look and let me know what you think.
Thanks,
Jason
Alexander Graf (1):
ACPI: allow longer device IDs
Jason A. Donenfeld (2):
random: add mechanism for VM forks to reinitialize crng
virt: vmgenid: introduce driver for reinitializing RNG on VM fork
MAINTAINERS | 1 + drivers/char/random.c | 50 +++++++++++----- drivers/virt/Kconfig | 11 ++++ drivers/virt/Makefile | 1 + drivers/virt/vmgenid.c | 100 ++++++++++++++++++++++++++++++++ include/linux/mod_devicetable.h | 2 +- include/linux/random.h | 1 + 7 files changed, 150 insertions(+), 16 deletions(-) create mode 100644 drivers/virt/vmgenid.c
Signature · 1 line
2.35.1
Jason A. Donenfeld
maintainerPATCH v5 1/3 random: add mechanism for VM forks to reinitialize crng
When a VM forks, we must immediately mix in additional information to the stream of random output so that two forks or a rollback don't produce the same stream of random numbers, which could have catastrophic cryptographic consequences. This commit adds a simple API, add_vmfork_ randomness(), for that, by force reseeding the crng.
This has the added benefit of also draining the entropy pool and setting its timer back, so that any old entropy that was there prior -- which could have already been used by a different fork, or generally gone stale -- does not contribute to the accounting of the next 256 bits.
--- drivers/char/random.c | 50 +++++++++++++++++++++++++++++------------- include/linux/random.h | 1 + 2 files changed, 36 insertions(+), 15 deletions(-)
drivers/char/random.c +35 -15
@@ -289,14 +289,14 @@ static DEFINE_PER_CPU(struct crng, crngs) = { };/* Used by crng_reseed() to extract a new seed from the input pool. */ -static bool drain_entropy (void *buf,size_t nbytes); +static bool drain_entropy (void *buf,size_t nbytes,bool force);/* * This extracts a new crng key from the input pool, but only if there is a -* sufficient amount of entropy available, in order to mitigate bruteforcing -* of newly added bits. +* sufficient amount of entropy available or force is true, in order to +* mitigate bruteforcing of newly added bits. */ -static void crng_reseed (void ) +static void crng_reseed (bool force) {unsigned long flags;unsigned long next_gen;
@@ -304,7 +304,7 @@ static void crng_reseed(void)bool finalize_init = false;/* Only reseed if we can, to prevent brute forcing a small amount of new bits. */ -if (!drain_entropy (key,sizeof (key))) +if (!drain_entropy (key,sizeof (key), force))return ;/*
@@ -406,7 +406,7 @@ static void crng_make_state(u32 chacha_state[CHACHA_STATE_WORDS],* in turn bumps the generation counter that we check below. */ if (unlikely (time_after (jiffies,READ_ONCE (base_crng.birth) +CRNG_RESEED_INTERVAL ))) -crng_reseed (); +crng_reseed (false);local_lock_irqsave (&crngs.lock, flags); crng =raw_cpu_ptr (&crngs);
@@ -771,10 +771,10 @@ EXPORT_SYMBOL(get_random_bytes_arch);* * Finally, extract entropy via these two, with the latter one * setting the entropy count to zero and extracting only if there -* is POOL_MIN_BITS entropy credited prior: +* is POOL_MIN_BITS entropy credited prior or force is true: * * static void extract_entropy(void *buf, size_t nbytes) -* static bool drain_entropy(void *buf, size_t nbytes) +* static bool drain_entropy(void *buf, size_t nbytes, bool force) * **********************************************************************/
@@ -832,7 +832,7 @@ static void credit_entropy_bits(size_t nbits) }while (cmpxchg (&input_pool.entropy_count, orig, entropy_count) != orig);if (crng_init <2 && entropy_count >=POOL_MIN_BITS ) -crng_reseed (); +crng_reseed (false); }/*
@@ -882,16 +882,16 @@ static void extract_entropy(void *buf, size_t nbytes) }/* -* First we make sure we have POOL_MIN_BITS of entropy in the pool, and then we -* set the entropy count to zero (but don't actually touch any data). Only then -* can we extract a new key with extract_entropy(). +* First we make sure we have POOL_MIN_BITS of entropy in the pool unless force +* is true, and then we set the entropy count to zero (but don't actually touch +* any data). Only then can we extract a new key with extract_entropy(). */ -static bool drain_entropy (void *buf,size_t nbytes) +static bool drain_entropy (void *buf,size_t nbytes,bool force) {unsigned int entropy_count;do { entropy_count =READ_ONCE (input_pool.entropy_count); -if (entropy_count <POOL_MIN_BITS ) +if (!force && entropy_count <POOL_MIN_BITS )return false; }while (cmpxchg (&input_pool.entropy_count, entropy_count,0 ) != entropy_count);extract_entropy (buf, nbytes);
@@ -915,6 +915,7 @@ static bool drain_entropy(void *buf, size_t nbytes)* void add_hwgenerator_randomness(const void *buffer, size_t count, * size_t entropy); * void add_bootloader_randomness(const void *buf, size_t size); +* void add_vmfork_randomness(const void *unique_vm_id, size_t size); * void add_interrupt_randomness(int irq); * * add_device_randomness() adds data to the input pool that
@@ -946,6 +947,10 @@ static bool drain_entropy(void *buf, size_t nbytes)* add_device_randomness(), depending on whether or not the configuration * option CONFIG_RANDOM_TRUST_BOOTLOADER is set. * +* add_vmfork_randomness() adds a unique (but not necessarily secret) ID +* representing the current instance of a VM to the pool, without crediting, +* and then force-reseeds the crng so that it takes effect immediately. +* * add_interrupt_randomness() uses the interrupt timing as random * inputs to the entropy pool. Using the cycle counters and the irq source * as inputs, it feeds the input pool roughly once a second or after 64
@@ -1173,6 +1178,21 @@ void add_bootloader_randomness(const void *buf, size_t size) }EXPORT_SYMBOL_GPL (add_bootloader_randomness); +/* +* Handle a new unique VM ID, which is unique, not secret, so we +* don't credit it, but we do immediately force a reseed after so +* that it's used by the crng posthaste. +*/ +void add_vmfork_randomness (const void *unique_vm_id,size_t size) +{ +add_device_randomness (unique_vm_id, size); +if (crng_ready ()) { +crng_reseed (true); +pr_notice ("crng reseeded due to virtual machine fork\n" ); + } +} +EXPORT_SYMBOL_GPL (add_vmfork_randomness); + struct fast_pool { union { u32 pool32[4];
@@ -1563,7 +1583,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)return -EPERM ;if (crng_init <2 )return -ENODATA ; -crng_reseed (); +crng_reseed (false);return 0 ;default :return -EINVAL ;
include/linux/random.h +1 -0
@@ -34,6 +34,7 @@ extern void add_input_randomness(unsigned int type, unsigned int code, extern void add_interrupt_randomness(int irq) __latent_entropy;extern void add_hwgenerator_randomness (const void *buffer,size_t count,size_t entropy); +extern void add_vmfork_randomness (const void *unique_vm_id,size_t size);extern void get_random_bytes (void *buf,size_t nbytes);extern int wait_for_random_bytes (void );
Signature · 1 line
2.35.1
Jason A. Donenfeld
maintainerPATCH v5 2/3 ACPI: allow longer device IDs
In reply to Jason A. DonenfeldFrom: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains _HID, _CID, and CLS entries of the respective devices. However, we squeeze them into struct acpi_device_id, which only has 9 bytes space to store the identifier. It originally had 16 bytes, but was changed to only have 9 in 6543becf26ff ("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by _CID with a value of "VM_Gen_Counter", which is longer than 9 characters.
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size, because the ulong in the same struct caused there to be 7 bytes of padding anyway.
This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
---
Hi Rafael & Len,
This patchset is directed toward you two specifically. Patches 1/3 and 3/3 have been through the ringer of review a bit already and do not specifically require your attention, but in v4 we wound up getting hung up on an ACPI API limitation. This v5 fixes that limitation with this 2/3 patch that you see here, with a trivial one line fix, which does require your attention.
Patches 1/3 and 3/3 will go through my random.git tree. However, 3/3 actually depends on this one here, 2/3, in order to compile without warnings (and be functional at all). Therefore, it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
Please have a look and let me know what you think.
Thanks,
Jason
include/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +1 -1
@@ -211,7 +211,7 @@ struct css_device_id {kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 9 +#define ACPI_ID_LEN 16struct acpi_device_id {__u8 id[ACPI_ID_LEN ];
Signature · 1 line
2.35.1
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 3 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Quoted 8 lines
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, we squeeze them into structacpi_device_id, which only has 9 bytes space to store the identifier. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Please clarify that this applies to the module metadata side of things. The ACPI subsystem already captures and exposes _HIDs and _CIDs that are longer than 8 characters, which is why simply increasing the size of this field is sufficient to create modules that can match devices that expose a CID that is longer than 8 bytes.
Quoted 11 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size, because the ulong in the same struct caused there to be 7 bytes of padding anyway.
The padding situation only applies to struct acpi_device_id, whereas ACPI_ID_LEN is used in other places as well. Also, the size of vmlinux only covers statically allocated instances in the core kernel, and most of the ACPI_ID_LEN uses are probably in drivers. So whether vmlinux changes size or not is not that relevant.
Quoted 6 lines
This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
Quoted 7 lines
Cc Ard Biesheuvel <[email protected]>Cc Len Brown <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Co-authored-by Jason A. Donenfeld <[email protected]>Signed-off-by Alexander Graf <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>
Patch 6543becf26ff was wrong to change ACPI_ID_LEN, because it failed to take into account any other uses of ACPI_ID_LEN, and did not bother to explain why the change was necessary in the context of what it was trying to achieve.
So, given that we need more than 8 characters to match drivers to devices exposed by Hyper-V (or other VMMs adhering to the VMGENID spec), I think this change is necessary and correct.
So, with the authorship/signoff corrected, and the commit log clarified,
Quoted 42 lines
---
Hi Rafael & Len,This patchset is directed toward you two specifically. Patches 1/3 and 3/3 have been through the ringer of review a bit already and do not specifically require your attention, but in v4 we wound up getting hung up on an ACPI API limitation. This v5 fixes that limitation with this 2/3 patch that you see here, with a trivial one line fix, which does require your attention.
Patches 1/3 and 3/3 will go through my random.git tree. However, 3/3 actually depends on this one here, 2/3, in order to compile without warnings (and be functional at all). Therefore, it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
Please have a look and let me know what you think.
Thanks,
Jasoninclude/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/mod_devicetable.h +1
-2@@ -211,7 +211,7 @@ struct css_device_id {kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 9 +#define ACPI_ID_LEN 16struct acpi_device_id {__u8 id[ACPI_ID_LEN ]; --2.35.1
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 57 lines · Ard Biesheuvel
Quoted 3 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Quoted 8 lines
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, we squeeze them into structacpi_device_id, which only has 9 bytes space to store the identifier. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.Please clarify that this applies to the module metadata side of things. The ACPI subsystem already captures and exposes
_HIDsand_CIDsthat are longer than 8 characters, which is why simply increasing the size of this field is sufficient to create modules that can match devices that expose a CID that is longer than 8 bytes.Quoted 11 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size, because the ulong in the same struct caused there to be 7 bytes of padding anyway.
The padding situation only applies to struct
acpi_device_id, whereasACPI_ID_LENis used in other places as well. Also, the size of vmlinux only covers statically allocated instances in the core kernel, and most of theACPI_ID_LENuses are probably in drivers. So whether vmlinux changes size or not is not that relevant.Quoted 6 lines
This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
Quoted 7 lines
Cc Ard Biesheuvel <[email protected]>Cc Len Brown <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Co-authored-by Jason A. Donenfeld <[email protected]>Signed-off-by Alexander Graf <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>
Quoted 5 lines
Patch
6543becf26ffwas wrong to changeACPI_ID_LEN, because it failed to take into account any other uses ofACPI_ID_LEN, and did not bother to explain why the change was necessary in the context of what it was trying to achieve.
Hmm, actually, ACPI_ID_LEN wasn't used outside of linux/mod_device_table.h before 6543becf26ff, so changing it at that point was fine.
I do wonder how much code is out there that blindly assumes the ACPI core will never deliver more than 8 bytes' worth of _HID/_CID, and subsequently runs off the end of a statically sized buffer.
Jason A. Donenfeld
maintainerRe: [PATCH v5 2/3] ACPI: allow longer device IDs
In reply to Ard BiesheuvelQuoted 7 lines · Ard Biesheuvel
Quoted 3 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Considering the investigative side ("why won't the _CID match?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here. If Alex objects he can just simply say, "hey feel free to remove me as author," and it'll be simple as that, and again doesn't involve your policing.
Quoted 10 lines
Quoted 9 lines
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, we squeeze them into structacpi_device_id, which only has 9 bytes space to store the identifier. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Quoted 5 lines
Please clarify that this applies to the module metadata side of things. The ACPI subsystem already captures and exposes
_HIDsand_CIDsthat are longer than 8 characters, which is why simply increasing the size of this field is sufficient to create modules that can match devices that expose a CID that is longer than 8 bytes.
Good point for strengthening the argument here. Will do.
Quoted 13 lines
Quoted 6 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.Quoted 6 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size, because the ulong in the same struct caused there to be 7 bytes of padding anyway.
Quoted 5 lines
The padding situation only applies to struct
acpi_device_id, whereasACPI_ID_LENis used in other places as well. Also, the size of vmlinux only covers statically allocated instances in the core kernel, and most of theACPI_ID_LENuses are probably in drivers. So whether vmlinux changes size or not is not that relevant.
I actually looked at every usage in the tree (there aren't that many) and couldn't find a single one where behavior changed, performance changed, or memory usage changed. I thought we looked together on IRC so I'm surprised to see you mention this, but maybe I misunderstood you. Anyway, I can't see the size increase impacting anything at all. If you see a case, this would be the time to mention that you see something. I didn't find anything though.
Quoted 4 lines
Patch
6543becf26ffwas wrong to changeACPI_ID_LEN, because it failed to take into account any other uses ofACPI_ID_LEN, and did not bother to explain why the change was necessary in the context of what it was trying to achieve.
I'm not sure there really were other usages back then. The commit message seems descriptive enough to me too. This was about cross compiling, so padding. But it certainly did seem to limit future
Quoted 3 lines · as you
So, given that we need more than 8 characters to match drivers to devices exposed by Hyper-V (or other VMMs adhering to the VMGENID spec), I think this change is necessary and correct.
Right, that's the idea.
Quoted 4 lines
So, with the authorship/signoff corrected, and the commit log clarified,
Reviewed-by Ard Biesheuvel <[email protected]>
Thanks.
Hopefully we'll hear from Rafael this week.
Jason
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 10 lines · Jason A. Donenfeld
Quoted 7 lines · Ard Biesheuvel
Quoted 3 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Quoted 9 lines
Considering the investigative side ("why won't the
_CIDmatch?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here.
Seriously? You want to go down the road again of poisoning the atmosphere here, and blaming everyone else for doing it? I had enough of that with the Zinc debacle, and I thought we had moved beyond that, after having collaborated constructively with you on various topics over the past couple of years.
Please stop with the ad hominems in response to criticism on factual aspects of your code. Putting someone else's authorship on code they did not write is not cool, and pointing that out is *not* what is making this space unpleasant.
And 'paperwork policing' is sadly an important aspect of a high profile open source project such as Linux.
Quoted 4 lines
If Alex objects he can just simply say, "hey feel free to remove me as author," and it'll be simple as that, and again doesn't involve your policing.
When you ask for my review, you get my review. If there are aspects of your contributions that are a priori exempt from criticism, I think you're in the wrong place.
Quoted 36 lines
Quoted 9 lines
Quoted 8 lines
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, we squeeze them into structacpi_device_id, which only has 9 bytes space to store the identifier. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.Quoted 5 lines
Please clarify that this applies to the module metadata side of things. The ACPI subsystem already captures and exposes
_HIDsand_CIDsthat are longer than 8 characters, which is why simply increasing the size of this field is sufficient to create modules that can match devices that expose a CID that is longer than 8 bytes.Good point for strengthening the argument here. Will do.
Quoted 13 lines
Quoted 6 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.Quoted 6 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size, because the ulong in the same struct caused there to be 7 bytes of padding anyway.
Quoted 5 lines
The padding situation only applies to struct
acpi_device_id, whereasACPI_ID_LENis used in other places as well. Also, the size of vmlinux only covers statically allocated instances in the core kernel, and most of theACPI_ID_LENuses are probably in drivers. So whether vmlinux changes size or not is not that relevant.
Quoted 8 lines
I actually looked at every usage in the tree (there aren't that many) and couldn't find a single one where behavior changed, performance changed, or memory usage changed. I thought we looked together on IRC so I'm surprised to see you mention this, but maybe I misunderstood you. Anyway, I can't see the size increase impacting anything at all. If you see a case, this would be the time to mention that you see something. I didn't find anything though.
If you did not check the rodata/data/bss sizes of all modules depending on this macro, or checked their memory usage at runtime, you cannot definitively say that nothing has changed.
*However*, as I argued below, using ACPI_ID_LEN to allocate a string that needs to hold a HID or CID provided by the ACPI subsystem might well result in a buffer overrun, as the ACPI subsystem will happily return longer strings.
So my conclusion is that the change is ok, which is why I gave my reviewed-by.
Quoted 27 lines
Quoted 4 lines
Patch
6543becf26ffwas wrong to changeACPI_ID_LEN, because it failed to take into account any other uses ofACPI_ID_LEN, and did not bother to explain why the change was necessary in the context of what it was trying to achieve.I'm not sure there really were other usages back then. The commit message seems descriptive enough to me too. This was about cross compiling, so padding. But it certainly did seem to limit future
Quoted 3 lines · as you
So, given that we need more than 8 characters to match drivers to devices exposed by Hyper-V (or other VMMs adhering to the VMGENID spec), I think this change is necessary and correct.
Right, that's the idea.
Quoted 4 lines
So, with the authorship/signoff corrected, and the commit log clarified,
Reviewed-by Ard Biesheuvel <[email protected]>Thanks.
Hopefully we'll hear from Rafael this week.
Jason
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 22 lines · Ard Biesheuvel
Quoted 19 lines · Jason A. Donenfeld
Quoted 7 lines · Ard Biesheuvel
Quoted 3 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Considering the investigative side ("why won't the
_CIDmatch?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here.
...
Quoted 8 lines
Please stop with the ad hominems in response to criticism on factual aspects of your code. Putting someone else's authorship on code they did not write is not cool, and pointing that out is *not* what is making this space unpleasant.
And 'paperwork policing' is sadly an important aspect of a high profile open source project such as Linux.
I typed this before reading your message on IRC, which reads:
"Alex looked at that patch before i sent it out and did not object to me keeping his authorship. I wouldn't have sent it out otherwise."
and so I stand corrected if this is true. But please, next time, please be more clear about these things.
Signature · 1 line
Ard.
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 25 lines · Ard Biesheuvel
Quoted 16 lines · Ard Biesheuvel
Quoted 15 lines · Jason A. Donenfeld
Quoted 5 lines · Ard Biesheuvel
Quoted 2 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Considering the investigative side ("why won't the
_CIDmatch?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here....
Quoted 7 lines
Please stop with the ad hominems in response to criticism on factual aspects of your code. Putting someone else's authorship on code they did not write is not cool, and pointing that out is *not* what is making this space unpleasant.
And 'paperwork policing' is sadly an important aspect of a high profile open source project such as Linux.
Quoted 7 lines
I typed this before reading your message on IRC, which reads:
"Alex looked at that patch before i sent it out and did not object to me keeping his authorship. I wouldn't have sent it out otherwise."
and so I stand corrected if this is true. But please, next time, please be more clear about these things.
Yes, he did reach out to me on a separate channel and I told him to go for it :). Sorry if I created some confusion with that.
Thanks,
Alex
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 33 lines · Alexander Graf
Quoted 30 lines · Ard Biesheuvel
Quoted 16 lines · Ard Biesheuvel
Quoted 15 lines · Jason A. Donenfeld
Quoted 5 lines · Ard Biesheuvel
Quoted 2 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Considering the investigative side ("why won't the
_CIDmatch?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here....
Quoted 7 lines
Please stop with the ad hominems in response to criticism on factual aspects of your code. Putting someone else's authorship on code they did not write is not cool, and pointing that out is *not* what is making this space unpleasant.
And 'paperwork policing' is sadly an important aspect of a high profile open source project such as Linux.I typed this before reading your message on IRC, which reads:
"Alex looked at that patch before i sent it out and did not object to me keeping his authorship. I wouldn't have sent it out otherwise."
Quoted 7 lines
Quoted 2 lines
and so I stand corrected if this is true. But please, next time, please be more clear about these things.
Yes, he did reach out to me on a separate channel and I told him to go for it :). Sorry if I created some confusion with that.
No, my bad. But in my defence, everyone on the original thread knows that this single oneline change was suggested by Jason, not you, and so seeing him posting it as your patch did confuse me a little.
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 36 lines · Ard Biesheuvel
Quoted 35 lines · Alexander Graf
Quoted 32 lines · Ard Biesheuvel
Quoted 16 lines · Ard Biesheuvel
Quoted 15 lines · Jason A. Donenfeld
Quoted 5 lines · Ard Biesheuvel
Quoted 2 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Considering the investigative side ("why won't the
_CIDmatch?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here....
Quoted 7 lines
Please stop with the ad hominems in response to criticism on factual aspects of your code. Putting someone else's authorship on code they did not write is not cool, and pointing that out is *not* what is making this space unpleasant.
And 'paperwork policing' is sadly an important aspect of a high profile open source project such as Linux.I typed this before reading your message on IRC, which reads:
"Alex looked at that patch before i sent it out and did not object to me keeping his authorship. I wouldn't have sent it out otherwise."
and so I stand corrected if this is true. But please, next time, please be more clear about these things.
Quoted 6 lines
Quoted 3 lines
Yes, he did reach out to me on a separate channel and I told him to go for it :). Sorry if I created some confusion with that.
No, my bad. But in my defence, everyone on the original thread knows that this single oneline change was suggested by Jason, not you, and so seeing him posting it as your patch did confuse me a little.
The idea came up 1y ago in conversations with Adrian when we tried to make _CID matching work. Unfortunately I did not file a patent for the mechanism to increase the array size until data fits :). It's such a revolutionary invention!
Back to seriousness, I'm pretty indifferent on the attribution for it. What I'm more interested in is a solution that allows us to match the correct identifier :). My take is that Jason just wanted to be nice and was trying to give credit.
Alex
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
Quoted 52 lines · Alexander Graf
Quoted 36 lines · Ard Biesheuvel
Quoted 35 lines · Alexander Graf
Quoted 32 lines · Ard Biesheuvel
Quoted 16 lines · Ard Biesheuvel
Quoted 15 lines · Jason A. Donenfeld
Quoted 5 lines · Ard Biesheuvel
Quoted 2 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
Please don't invent patch authors like that. Alex's patch that started this discussion was completely different.
Considering the investigative side ("why won't the
_CIDmatch?") and most the commit message were Alex's, and that those things comprise 95% of what this patch is, and that the code change itself isn't even part of anything Turing complete, I most certainly did not feel comfortable stripping Alex's authorship. Instead I added myself as a co-author at the bottom. When in doubt, err on the side of crediting others. Alex also took a look at this patch, I am under the impression of at least, before it went out. Let's minimize the paperwork policing, okay? I think it'd make for a much more pleasant space here....
Quoted 7 lines
Please stop with the ad hominems in response to criticism on factual aspects of your code. Putting someone else's authorship on code they did not write is not cool, and pointing that out is *not* what is making this space unpleasant.
And 'paperwork policing' is sadly an important aspect of a high profile open source project such as Linux.I typed this before reading your message on IRC, which reads:
"Alex looked at that patch before i sent it out and did not object to me keeping his authorship. I wouldn't have sent it out otherwise."
and so I stand corrected if this is true. But please, next time, please be more clear about these things.
Quoted 6 lines
Quoted 3 lines
Yes, he did reach out to me on a separate channel and I told him to go for it :). Sorry if I created some confusion with that.
No, my bad. But in my defence, everyone on the original thread knows that this single oneline change was suggested by Jason, not you, and so seeing him posting it as your patch did confuse me a little.
The idea came up 1y ago in conversations with Adrian when we tried to make
_CIDmatching work. Unfortunately I did not file a patent for the mechanism to increase the array size until data fits :). It's such a revolutionary invention!
Quoted 5 lines
Back to seriousness, I'm pretty indifferent on the attribution for it. What I'm more interested in is a solution that allows us to match the correct identifier :). My take is that Jason just wanted to be nice and was trying to give credit.
Giving credit is nice, but I do think that obfuscating authorship like this is generally not preferred.
But in this particular case, it hardly matters, so let's not debate this any further.
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
In reply to Jason A. DonenfeldQuoted 10 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, we squeeze them into structacpi_device_id, which only has 9 bytes space to store the identifier. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Quoted 8 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this
This is only true for 64bit systems where padding automatically bloated to 9 byte array to 16. I still believe the patch is fine as it is, but there will be minor .rodata overhead on 32bit targets which you may want to quantify in the patch description.
Thanks a lot for sending this out! And let's hope that 16 bytes is enough for everyone.
Alex
Quoted 56 lines
doesn't actually increase vmlinux size, because the ulong in the same struct caused there to be 7 bytes of padding anyway.
This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
Cc Ard Biesheuvel <[email protected]>Cc Len Brown <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Co-authored-by Jason A. Donenfeld <[email protected]>Signed-off-by Alexander Graf <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>---
Hi Rafael & Len,This patchset is directed toward you two specifically. Patches 1/3 and 3/3 have been through the ringer of review a bit already and do not specifically require your attention, but in v4 we wound up getting hung up on an ACPI API limitation. This v5 fixes that limitation with this 2/3 patch that you see here, with a trivial one line fix, which does require your attention.
Patches 1/3 and 3/3 will go through my random.git tree. However, 3/3 actually depends on this one here, 2/3, in order to compile without warnings (and be functional at all). Therefore, it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
Please have a look and let me know what you think.
Thanks,
Jasoninclude/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/mod_devicetable.h +1
-2@@ -211,7 +211,7 @@ struct css_device_id {kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 9 +#define ACPI_ID_LEN 16struct acpi_device_id {__u8 id[ACPI_ID_LEN ]; --
Quoted 2 lines
2.35.1
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Jason A. Donenfeld
maintainerRe: [PATCH v5 2/3] ACPI: allow longer device IDs
Hi Alex,
Quoted 9 lines · Alexander Graf
Quoted 3 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this
This is only true for 64bit systems where padding automatically bloated to 9 byte array to 16. I still believe the patch is fine as it is, but there will be minor .rodata overhead on 32bit targets which you may want to quantify in the patch description.
Good point. So I just tried this out with a 32-bit i686 kernel and the results are the same again for the size of vmlinux. I then ran objdump --headers and looked at the size of the .rodata section, where it's also the same. I'm not quite sure what to make of this, as it's not what I was expecting, but I think I tested it right. So maybe we're lucky here?
Jason
Jason A. Donenfeld
maintainerRe: [PATCH v5 2/3] ACPI: allow longer device IDs
Hey again,
Quoted 14 lines · Jason A. Donenfeld
Hi Alex,
Quoted 9 lines · Alexander Graf
Quoted 3 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this
This is only true for 64bit systems where padding automatically bloated to 9 byte array to 16. I still believe the patch is fine as it is, but there will be minor .rodata overhead on 32bit targets which you may want to quantify in the patch description.
Quoted 6 lines
Good point. So I just tried this out with a 32-bit i686 kernel and the results are the same again for the size of vmlinux. I then ran
objdump --headersand looked at the size of the .rodata section, where it's also the same. I'm not quite sure what to make of this, as it's not what I was expecting, but I think I tested it right. So maybe we're lucky here?
I tried a little harder to get _some_ difference on 32-bit, and managed to get one by doing i386_defconfig and then switching off modules to make all M into Y, and then compared sizes:
vmlinux: 25590780 -> 25598972, so a 0.032% increase.
bzImage: 8698944 -> 8699424, so a 0.0055% increase.
So it does increase, ever so slightly, but a) on 32-bit, and b) a super, super tiny amount.
In other words, I still think this patch is very much a-okay. But very eager to hear from Rafael on the approach.
Jason
Rafael J. Wysocki
maintainerRe: [PATCH v5 2/3] ACPI: allow longer device IDs
+Mika, Andy and Hans in case they have something to add
Quoted 29 lines · Jason A. Donenfeld
Hey again,
Quoted 14 lines · Jason A. Donenfeld
Hi Alex,
Quoted 9 lines · Alexander Graf
Quoted 3 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this
This is only true for 64bit systems where padding automatically bloated to 9 byte array to 16. I still believe the patch is fine as it is, but there will be minor .rodata overhead on 32bit targets which you may want to quantify in the patch description.
Quoted 6 lines
Good point. So I just tried this out with a 32-bit i686 kernel and the results are the same again for the size of vmlinux. I then ran
objdump --headersand looked at the size of the .rodata section, where it's also the same. I'm not quite sure what to make of this, as it's not what I was expecting, but I think I tested it right. So maybe we're lucky here?I tried a little harder to get _some_ difference on 32-bit, and managed to get one by doing
i386_defconfigand then switching off modules to make all M into Y, and then compared sizes:
Quoted 8 lines
vmlinux: 25590780 -> 25598972, so a 0.032% increase.
bzImage: 8698944 -> 8699424, so a 0.0055% increase.So it does increase, ever so slightly, but a) on 32-bit, and b) a super, super tiny amount.
In other words, I still think this patch is very much a-okay. But very eager to hear from Rafael on the approach.
Increasing the ACPI_ID_LEN value is fine with me, but the patch changelog is not entirely accurate.
The ACPI subsystem uses struct acpi_device_id mostly (if not only) for device ID matching and it is generally used for creating lists of ACPI device IDs in drivers (and allow/deny lists etc). The device IDs extracted from the ACPI tables can be longer than ACPI_ID_LEN.
This means that drivers cannot match device IDs longer than 8 characters (excluding the terminating 0), because the IDs in the lists used by them for ID matching cannot be longer than this and not because the ACPI subsystem is limited by that value.
Jason A. Donenfeld
maintainerRe: [PATCH v5 2/3] ACPI: allow longer device IDs
Hi Rafael,
Quoted 8 lines · Rafael J. Wysocki
Increasing the
ACPI_ID_LENvalue is fine with me, but the patch changelog is not entirely accurate.The ACPI subsystem uses struct
acpi_device_idmostly (if not only) for device ID matching and it is generally used for creating lists of ACPI device IDs in drivers (and allow/deny lists etc). The device IDs extracted from the ACPI tables can be longer thanACPI_ID_LEN.
Quoted 4 lines
This means that drivers cannot match device IDs longer than 8 characters (excluding the terminating 0), because the IDs in the lists used by them for ID matching cannot be longer than this and not because the ACPI subsystem is limited by that value.
Thanks for your notes there. I think Ard more or less pointed out something similar too. I'll amend the commit message, send a v2, and hopefully this change is okay with Mika/Andy/Hans.
Regards,
Jason
Jason A. Donenfeld
maintainerPATCH v6 2/3 ACPI: allow longer device IDs
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains _HID, _CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs into acpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in 6543becf26ff ("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by _CID with a value of "VM_Gen_Counter", which is longer than 9 characters.
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size on 64-bit, because the ulong in the same struct caused there to be 7 bytes of padding anyway, and when doing a s/M/Y/g i386_defconfig build, the bzImage only increased by 0.0055%, so negligible.
This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
---
Hi Rafael,
This patch is directed toward you specifically. The first and last patch of the series this is part of have been through the ringer of review a bit already and do not specifically require your attention, but we wound up getting hung up on an ACPI ID matching API limitation. This patch fixes that limitation with this patch that you see here, with a trivial one line fix, which does require your attention.
The other patches will go through my random.git tree naturally, but because those patches depend on this one here, in order to compile without warnings (and be functional at all), it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
This v6 updates the commit message.
Please have a look and let me know what you think.
Thanks,
Jason
include/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +1 -1
@@ -211,7 +211,7 @@ struct css_device_id {kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 9 +#define ACPI_ID_LEN 16struct acpi_device_id {__u8 id[ACPI_ID_LEN ];
Signature · 1 line
2.35.1
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 13 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Quoted 4 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.
Then why do we not see the ECR from somebody to update the spec or to fix MS' abuse of it?
I believe _this_ should be the prerequisite to the proposed change.
Quoted 11 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size on 64-bit, because the ulong in the same struct caused there to be 7 bytes of padding anyway, and when doing a s/M/Y/g
i386_defconfigbuild, the bzImage only increased by 0.0055%, so negligible.This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Hi Andy,
Quoted 3 lines · Andy Shevchenko
Then why do we not see the ECR from somebody to update the spec or to fix MS' abuse of it?
I believe _this_ should be the prerequisite to the proposed change.
Sorry, but no; that seems like a ridiculous requirement. There's virtual "hardware" out there that is behaving like this. It serves an important security function. There are no technical downsides to making the change. It works well.
Yet you're upset that they didn't follow the rules. Indeed, tsk tsk on Microsoft. But that doesn't mean Linux users should suffer and have poorer security than Windows.
This kind of thing happens all the time. We do our best to find the cleanest solution to the problem, and live with it. Linux isn't a one-hundred-per-cent-by-the-spec operating system, because the things it works with are often not one-hundred-per-cent-by-the-spec. We even have quirks tables. It's part of life.
And in this case, the solution is so straightforward that it doesn't even require anything closely resembling a "hack" or a layering violation. And that space is already being used (zero filled) anyway because of struct padding.
This fix is the "clean" way of doing it. Why make this harder than it needs to be?
Jason
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Andy ShevchenkoQuoted 15 lines · Andy Shevchenko
Quoted 12 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.
Quoted 9 lines
Quoted 4 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.Then why do we not see the ECR from somebody to update the spec or to fix MS' abuse of it?
I believe _this_ should be the prerequisite to the proposed change.
What exactly are you suggesting here? That the contributor of this patch joins the UEFI forum as an individual adopter in order to get the ACPI spec updated before we can advance with this patch? Or that he works with Microsoft to get them to refrain from violating it?
I don't think that is reasonable or realistic. The kernel is already riddled with UEFI and ACPI quirks that are only there because some teams at MS don't take the ACPI spec too literally (which is why they have their own AML compiler, for one), and PC vendors only care about the Windows sticker, so they don't care about the ACPI spec either.
So I don't think this is the right time to get pedantic about this. Our ACPI subsystem already deals with CIDs that are longer than 8 characters (which are btw permitted by the ACPI spec for bus topology related metadata), the only thing being changed here is the ability to actually match against such identifiers.
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 36 lines · Ard Biesheuvel
Quoted 15 lines · Andy Shevchenko
Quoted 12 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.Quoted 8 lines
Quoted 4 lines
Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.Then why do we not see the ECR from somebody to update the spec or to fix MS' abuse of it?
I believe _this_ should be the prerequisite to the proposed change.What exactly are you suggesting here? That the contributor of this patch joins the UEFI forum as an individual adopter in order to get the ACPI spec updated before we can advance with this patch? Or that he works with Microsoft to get them to refrain from violating it?
I don't think that is reasonable or realistic. The kernel is already riddled with UEFI and ACPI quirks that are only there because some teams at MS don't take the ACPI spec too literally (which is why they have their own AML compiler, for one), and PC vendors only care about the Windows sticker, so they don't care about the ACPI spec either.
Quoted 5 lines
So I don't think this is the right time to get pedantic about this. Our ACPI subsystem already deals with CIDs that are longer than 8 characters (which are btw permitted by the ACPI spec for bus topology related metadata), the only thing being changed here is the ability to actually match against such identifiers.
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issue
AND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
From my side, regarding (1), I'm basically just waiting for Rafael's "Acked-by" (or an explicit nack) so I can put this in my tree and move on.
Jason
RE: [PATCH 2/3 v6] ACPI: allow longer device IDs
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022 1:55 PM
Quoted 16 lines
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.
Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Michael
Quoted 6 lines
From my side, regarding (1), I'm basically just waiting for Rafael's "Acked-by" (or an explicit nack) so I can put this in my tree and move on.
Jason
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 5 lines · Michael Kelley (LINUX)
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
I should note that QEMU and VMware also support this too. So, yea, I guess that boat has sailed.
Should that Hyper-V team do the ECR thing Andy was talking about?
Jason
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Michael Kelley (LINUX)Quoted 37 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022 1:55 PM
Quoted 16 lines
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.
Quoted 3 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Thanks for chiming in.
Why not do something like
Name (_CID, Package (2) { "VM_GEN_COUNTER", "VMGENCTR" } )
?
That way, older clients can match on the existing _CID and new clients can match on the spec compliant one.
RE: [PATCH 2/3 v6] ACPI: allow longer device IDs
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:22 PM
Quoted 47 lines
Quoted 2 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022
1:55 PM
Quoted 35 lines
Quoted 16 lines
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.Quoted 3 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Thanks for chiming in.
Quoted 8 lines
Why not do something like
Name (
_CID, Package (2) { "VM_GEN_COUNTER", "VMGENCTR" } )?
That way, older clients can match on the existing
_CIDand new clients can match on the spec compliant one.
I'll run this by the Hyper-V guys. I don't have the ACPI expertise to disagree with them when they say they can't change it. :-(
Michael
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 53 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:22 PM
Quoted 51 lines
Quoted 2 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022
1:55 PM
Quoted 35 lines
Quoted 16 lines
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.Quoted 3 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Thanks for chiming in.
Why not do something like
Name (
_CID, Package (2) { "VM_GEN_COUNTER", "VMGENCTR" } )
Quoted 8 lines
Quoted 4 lines
?
That way, older clients can match on the existing
_CIDand new clients can match on the spec compliant one.I'll run this by the Hyper-V guys. I don't have the ACPI expertise to disagree with them when they say they can't change it. :-(
Yes, please, even if it makes no difference for this particular patch.
RE: [PATCH 2/3 v6] ACPI: allow longer device IDs
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:47 PM
Quoted 58 lines
Quoted 55 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:22 PM
Quoted 53 lines
Quoted 2 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022
1:55 PM
Quoted 35 lines
Quoted 16 lines
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.Quoted 3 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Thanks for chiming in.
Why not do something like
Name (
_CID, Package (2) { "VM_GEN_COUNTER", "VMGENCTR" } )?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
That way, older clients can match on the existing
_CIDand new clients can match on the spec compliant one.I'll run this by the Hyper-V guys. I don't have the ACPI expertise to disagree with them when they say they can't change it. :-(
Yes, please, even if it makes no difference for this particular patch.
The Hyper-V guys pass along their thanks for your suggestion. They have created an internal build with the change and verified that it preserves compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good. It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.
Michael
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Hi Michael,
Quoted 98 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:47 PM
Quoted 81 lines
Quoted 78 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:22 PM
Quoted 74 lines
Quoted 3 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022
1:55 PM
Quoted 51 lines
Quoted 19 lines
Hi Andy,
Quoted 5 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with
the comment that this is an issueQuoted 8 lines
AND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 11 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means
go for it. I have no idea how to do this myself; Ard said something
about joining the UEFI forum as an individual something or another but
I don't think I'm the man for the job there. Is this something that
Intel can do with their existing membership (is that the right term?)
at the UEFI forum? Or maybe a Microsoft engineer on the list?My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue
was raised during the previous attempt to implement the functionality
in Linux. I've talked with the Hyper-V dev manager, and they acknowledge
that the ACPI entry Hyper-V provides to guest VMs violates the spec.
But
changing to an identifier that meets the spec is problematic because
of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V
provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point
Hyper-V
is not planning to change anything.Quoted 4 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread,
it seems to be one that we will have to live with.Thanks for chiming in.
Why not do something like
Name (
_CID, Package (2) { "VM_GEN_COUNTER", "VMGENCTR" } )?
That way, older clients can match on the existing
_CIDand new clients
can match on the spec compliant one.Quoted 6 lines
Quoted 4 lines
I'll run this by the Hyper-V guys. I don't have the ACPI expertise to disagree
with them when they say they can't change it. :-(Yes, please, even if it makes no difference for this particular patch.
The Hyper-V guys pass along their thanks for your suggestion. They have created an internal build with the change and verified that it preserves compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good.
It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.
Quoted 2 lines
Michael
Do you want to send a patch against the crng/random.git tree adding that new id?
Jason
RE: [PATCH 2/3 v6] ACPI: allow longer device IDs
From: Jason A. Donenfeld <[email protected]> Sent: Tuesday, March 22, 2022 1:12 PM
Quoted 12 lines
Hi Michael,
Quoted 9 lines
The Hyper-V guys pass along their thanks for your suggestion. They have created an internal build with the change and verified that it preserves compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good.
It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.
Quoted 4 lines
Quoted 2 lines
Michael
Do you want to send a patch against the crng/random.git tree adding that new id?
I've sent a patch.
Michael
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Michael Kelley (LINUX)Quoted 67 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:47 PM
Quoted 65 lines
Quoted 61 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Monday, February 28, 2022 2:22 PM
Quoted 47 lines
Quoted 2 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022
1:55 PM
Quoted 35 lines
Quoted 16 lines
Hi Andy,
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.Quoted 3 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Thanks for chiming in.
Quoted 8 lines
Why not do something like
Name (
_CID, Package (2) { "VM_GEN_COUNTER", "VMGENCTR" } )?
That way, older clients can match on the existing
_CIDand new clients can match on the spec compliant one.I'll run this by the Hyper-V guys. I don't have the ACPI expertise to disagree with them when they say they can't change it. :-(
Quoted 9 lines
Quoted 1 line
Yes, please, even if it makes no difference for this particular patch.
The Hyper-V guys pass along their thanks for your suggestion. They have created an internal build with the change and verified that it preserves compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good. It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.
Thanks for reporting back.
Will the spec be updated accordingly?
RE: [PATCH 2/3 v6] ACPI: allow longer device IDs
From: Ard Biesheuvel <[email protected]> Sent: Tuesday, March 22, 2022 3:07 PM
Quoted 12 lines
Quoted 8 lines · Michael Kelley (LINUX)
The Hyper-V guys pass along their thanks for your suggestion. They have created an internal build with the change and verified that it preserves compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good. It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.
Quoted 3 lines
Thanks for reporting back.
Will the spec be updated accordingly?
The Hyper-V team is looking into updating the spec. The document is 10 years old, so they need to find the original source for the PDF.
Michael
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 17 lines · Michael Kelley (LINUX)
From: Ard Biesheuvel <[email protected]> Sent: Tuesday, March 22, 2022 3:07 PM
Quoted 15 lines
Quoted 11 lines · Michael Kelley (LINUX)
The Hyper-V guys pass along their thanks for your suggestion. They have
created an internal build with the change and verified that it preserves
compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good.
It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.
Quoted 7 lines
Quoted 3 lines
Thanks for reporting back.
Will the spec be updated accordingly?
The Hyper-V team is looking into updating the spec. The document is 10 years old, so they need to find the original source for the PDF.
Lol, here's the docx:
https://download.microsoft.com/download/3/1/C/31CFC307-98CA-4CA5-914C-D9772691E214/VirtualMachineGenerationID.docx
RE: [PATCH 2/3 v6] ACPI: allow longer device IDs
From: Jason A. Donenfeld <[email protected]> Sent: Thursday, March 24, 2022 12:45 PM
Quoted 21 lines · Michael Kelley (LINUX)
Quoted 19 lines
From: Ard Biesheuvel <[email protected]> Sent: Tuesday, March 22, 2022 3:07 PM
Quoted 17 lines
Quoted 11 lines · Michael Kelley (LINUX)
The Hyper-V guys pass along their thanks for your suggestion. They have
created an internal build with the change and verified that it preserves
compatibility with Windows guests. I've tested with Linux guests and Jason's new driver (modified to look for "VMGENCTR"), and it all looks good.
It will take a little while to wend its way through the Windows/Hyper-V release system, but they are planning to take the change.Thanks for reporting back.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Will the spec be updated accordingly?
The Hyper-V team is looking into updating the spec. The document is 10 years old, so they need to find the original source for the PDF.
Lol, here's the docx:
https://download.microsoft.com/download/3/1/C/31CFC307-98CA-4CA5-914C-D9772691E214/VirtualMachineGenerationID.docx
Indeed! My mistake. I just assumed it was a PDF without even looking at it. :-( Somebody internally here also just commented that it was weird to have a .docx file posted for download.
Regardless, that removes one hurdle to making updates!
Michael
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Michael Kelley (LINUX)Quoted 33 lines · Michael Kelley (LINUX)
From: Jason A. Donenfeld <[email protected]> Sent: Monday, February 28, 2022 1:55 PM
Quoted 13 lines
Quoted 10 lines · Andy Shevchenko
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueAND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.Quoted 6 lines
Oh, okay, that makes sense. If you want to get (2) going, by all means go for it. I have no idea how to do this myself; Ard said something about joining the UEFI forum as an individual something or another but I don't think I'm the man for the job there. Is this something that Intel can do with their existing membership (is that the right term?) at the UEFI forum? Or maybe a Microsoft engineer on the list?
My team at Microsoft, which works on Linux, filed a bug on this issue against the Hyper-V team about a year ago, probably when the issue was raised during the previous attempt to implement the functionality in Linux. I've talked with the Hyper-V dev manager, and they acknowledge that the ACPI entry Hyper-V provides to guest VMs violates the spec. But changing to an identifier that meets the spec is problematic because of backwards compatibility with Windows guests on Hyper-V that consume the current identifier. There's no practical way to have Hyper-V provide a conformant identifier AND fix all the Windows guests out in
the wild to consume the new identifier. As a result, at this point Hyper-V
is not planning to change anything.
Quoted 2 lines
It's a lousy state-of-affairs, but as mentioned previously in this thread, it seems to be one that we will have to live with.
Yes, my point of 2) is targeting the following:
a) MS should be notified
b) MS must try very hard to avoid similar problems in the future, they very well may discuss the matters in ASWG with other companies
c) the spec will be fixed for the future versions, while the current one will live for the backward compatibility only
Frankly I'm a bit frustrated that it's not the first time MS violates the ACPI spec, while being a member of ASWG.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Andy ShevchenkoHi Andy,
Quoted 41 lines · Andy Shevchenko
Quoted 31 lines · Ard Biesheuvel
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter. Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.Quoted 3 lines
Then why do we not see the ECR from somebody to update the spec or to fix MS' abuse of it?
I believe _this_ should be the prerequisite to the proposed change.What exactly are you suggesting here? That the contributor of this patch joins the UEFI forum as an individual adopter in order to get the ACPI spec updated before we can advance with this patch? Or that he works with Microsoft to get them to refrain from violating it?
I don't think that is reasonable or realistic. The kernel is already riddled with UEFI and ACPI quirks that are only there because some teams at MS don't take the ACPI spec too literally (which is why they have their own AML compiler, for one), and PC vendors only care about the Windows sticker, so they don't care about the ACPI spec either.
Quoted 5 lines
So I don't think this is the right time to get pedantic about this. Our ACPI subsystem already deals with CIDs that are longer than 8 characters (which are btw permitted by the ACPI spec for bus topology related metadata), the only thing being changed here is the ability to actually match against such identifiers.
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issue
Quoted 6 lines
AND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.
While trying to revalidate whether this really is breaking the spec, I've tried to reread the respective section in it and I'm afraid that it may be valid use of the _CID identifier:
"""
6.1.2 _CID (Compatible ID)
This optional object is used to supply OSPM with a device’s Plug and Play-Compatible Device ID. Use _CID objects when a device has no other defined hardware standard method to report its compatible IDs. The _CID object is valid only within a Full Device Descriptor. An _HID object must also be present.
Arguments:
None
Return Value:
An Integer or String containing a single CID or a Package containing a list of CIDs A _CID object evaluates to either:
*
A single Compatible Device ID
*
A package of Compatible Device IDs for the device – in the order of preference, highest preference first.
Each Compatible Device ID must be either:
*
A valid HID value (a 32-bit compressed EISA type ID or a string such as “ACPI0004”).
*
A string that uses a bus-specific nomenclature. For example, _CID can be used to specify the PCI ID. The format of a PCI ID string is one of the following:
"PCI\CC_ccss" "PCI\CC_ccsspp" "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss&REV_rr" "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss" "PCI\VEN_vvvv&DEV_dddd&REV_rr" "PCI\VEN_vvvv&DEV_dddd"
"""
In this case, you could interpret things as looking at "bus-specific nomenclature" case which even in the examples mentioned in the spec exceeds the 8 character limit we impose on the matching logic today.
There still is spec violation in Hyper-V's VMGenID device's _HID value which doesn't follow the PNP format, but that's not relevant here. _CID doesn't seem to have the same restrictions?
Alex
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Re: Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 103 lines · Alexander Graf
Hi Andy,
Quoted 41 lines · Andy Shevchenko
Quoted 31 lines · Ard Biesheuvel
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter. Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.Quoted 3 lines
Then why do we not see the ECR from somebody to update the spec or to fix MS' abuse of it?
I believe _this_ should be the prerequisite to the proposed change.What exactly are you suggesting here? That the contributor of this patch joins the UEFI forum as an individual adopter in order to get the ACPI spec updated before we can advance with this patch? Or that he works with Microsoft to get them to refrain from violating it?
I don't think that is reasonable or realistic. The kernel is already riddled with UEFI and ACPI quirks that are only there because some teams at MS don't take the ACPI spec too literally (which is why they have their own AML compiler, for one), and PC vendors only care about the Windows sticker, so they don't care about the ACPI spec either.
Quoted 5 lines
So I don't think this is the right time to get pedantic about this. Our ACPI subsystem already deals with CIDs that are longer than 8 characters (which are btw permitted by the ACPI spec for bus topology related metadata), the only thing being changed here is the ability to actually match against such identifiers.
My point is that this is clear abuse of the spec and:
1) we have to enable the broken, because it is already in the wild with the comment that this is an issueQuoted 6 lines
AND
2) issue an ECR / work with MS to make sure they understand the problem.
This can be done in parallel. What I meant as a prerequisite is to start doing
2) while we have 1) on table.While trying to revalidate whether this really is breaking the spec, I've tried to reread the respective section in it and I'm afraid that it may be valid use of the
_CIDidentifier:"""
6.1.2
_CID(Compatible ID)This optional object is used to supply OSPM with a device’s Plug and Play-Compatible Device ID. Use
_CIDobjects when a device has no other defined hardware standard method to report its compatible IDs. The_CIDobject is valid only within a Full Device Descriptor. An_HIDobject must also be present.Arguments:
None
Return Value:
An Integer or String containing a single CID or a Package containing a list of CIDs A_CIDobject evaluates to either:*
A single Compatible Device ID
*
A package of Compatible Device IDs for the device – in the order of preference, highest preference first.
Each Compatible Device ID must be either:
*
A valid HID value (a 32-bit compressed EISA type ID or a string such as “ACPI0004”).
*
A string that uses a bus-specific nomenclature. For example,
_CIDcan be used to specify the PCI ID. The format of a PCI ID string is one of the following:"PCI\CC_ccss" "PCI\CC_ccsspp" "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss&REV_rr" "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss" "PCI\VEN_vvvv&DEV_dddd&REV_rr" "PCI\VEN_vvvv&DEV_dddd"
Quoted 6 lines
"""
In this case, you could interpret things as looking at "bus-specific nomenclature" case which even in the examples mentioned in the spec exceeds the 8 character limit we impose on the matching logic today.
This is what I was referring to when I mentioned bus topology related metadata.
This is why those uses of ACPI_ID_LEN outside of struct acpi_device_id may potentially be dangerous, given that _CIDs are apparently effectively unbounded in size. But relying on this to justify the "VM_GEN_COUNTER" CID is a bit of a stretch, IMO.
Quoted 4 lines
There still is spec violation in Hyper-V's VMGenID device's
_HIDvalue which doesn't follow the PNP format, but that's not relevant here._CIDdoesn't seem to have the same restrictions?
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Jason A. DonenfeldHi,
Quoted 31 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size on 64-bit, because the ulong in the same struct caused there to be 7 bytes of padding anyway, and when doing a s/M/Y/g
i386_defconfigbuild, the bzImage only increased by 0.0055%, so negligible.This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
Quoted 11 lines
Signed-off-by Alexander Graf <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Mika Westerberg <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Hans de Goede <[email protected]>Cc Len Brown <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Ard Biesheuvel <[email protected]>Co-authored-by Jason A. Donenfeld <[email protected]>[Jason: reworked commit message a bit, went with len=16 approach.]Signed-off-by Jason A. Donenfeld <[email protected]>
The need for this is a bit meh, but I have no objections against solving it this way:
Regards,
Hans
Quoted 41 lines
---
Hi Rafael,This patch is directed toward you specifically. The first and last patch of the series this is part of have been through the ringer of review a bit already and do not specifically require your attention, but we wound up getting hung up on an ACPI ID matching API limitation. This patch fixes that limitation with this patch that you see here, with a trivial one line fix, which does require your attention.
The other patches will go through my random.git tree naturally, but because those patches depend on this one here, in order to compile without warnings (and be functional at all), it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
This v6 updates the commit message.
Please have a look and let me know what you think.
Thanks,
Jasoninclude/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/mod_devicetable.h +1
-1@@ -211,7 +211,7 @@ struct css_device_id {kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 9 +#define ACPI_ID_LEN 16struct acpi_device_id {__u8 id[ACPI_ID_LEN ];
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Hi Hans,
Quoted 1 line · Hans de Goede
Acked-by Hans de Goede <[email protected]>
Thanks for the Ack. I still need Rafael's Ack to take this through my random.git tree, right? Or are you two one in the same when it comes to that? Trying not to step on toes if possible.
Jason
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
Hi,
Quoted 7 lines · Jason A. Donenfeld
Hi Hans,
Quoted 1 line · Hans de Goede
Acked-by Hans de Goede <[email protected]>Thanks for the Ack. I still need Rafael's Ack to take this through my random.git tree, right?
Right.
Quoted 2 lines
Or are you two one in the same when it comes
to that? Trying not to step on toes if possible.
No, I'm the drivers/platform/x86 subsys maintainer and as such do a lot with ACPI too, but Rafael is the ACPI subsys maintainer.
Regards,
Hans
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Hans de GoedeQuoted 3 lines · Hans de Goede
Quoted 1 line · Jason A. Donenfeld
Co-authored-by Jason A. Donenfeld <[email protected]>
Official tag is Co-developed-by
Quoted 2 lines
Quoted 2 lines
[Jason: reworked commit message a bit, went with len=16 approach.]Signed-off-by Jason A. Donenfeld <[email protected]>
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jason A. Donenfeld
maintainerRe: [PATCH 2/3 v6] ACPI: allow longer device IDs
Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Hans de Goede
Quoted 1 line · Jason A. Donenfeld
Co-authored-by Jason A. Donenfeld <[email protected]>Official tag is Co-developed-by
Thanks, will adjust.
Re: [PATCH 2/3 v6] ACPI: allow longer device IDs
In reply to Jason A. DonenfeldQuoted 61 lines · Jason A. Donenfeld
From: Alexander Graf <[email protected]>
We create a list of ACPI "PNP" IDs which contains
_HID,_CID, and CLS entries of the respective devices. However, when making structs for matching, we squeeze those IDs intoacpi_device_id, which only has 9 bytes space to store the identifier. The subsystem actually captures the full length of the IDs, and the modalias has the full length, but this struct we use for matching is limited. It originally had 16 bytes, but was changed to only have 9 in6543becf26ff("mod/file2alias: make modalias generation safe for cross compiling"), presumably on the theory that it would match the ACPI spec so it didn't matter.Unfortunately, while most people adhere to the ACPI specs, Microsoft decided that its VM Generation Counter device [1] should only be identifiable by
_CIDwith a value of "VM_Gen_Counter", which is longer than 9 characters.To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this doesn't actually increase vmlinux size on 64-bit, because the ulong in the same struct caused there to be 7 bytes of padding anyway, and when doing a s/M/Y/g
i386_defconfigbuild, the bzImage only increased by 0.0055%, so negligible.This patch is a prerequisite to add support for VMGenID in Linux, the subsequent patch in this series. It has been confirmed to also work on the udev/modalias side in userspace.
Signed-off-by Alexander Graf <[email protected]>Cc Rafael J. Wysocki <[email protected]>Cc Mika Westerberg <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Hans de Goede <[email protected]>Cc Len Brown <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Ard Biesheuvel <[email protected]>Co-authored-by Jason A. Donenfeld <[email protected]>[Jason: reworked commit message a bit, went with len=16 approach.]Signed-off-by Jason A. Donenfeld <[email protected]>---
Hi Rafael,This patch is directed toward you specifically. The first and last patch of the series this is part of have been through the ringer of review a bit already and do not specifically require your attention, but we wound up getting hung up on an ACPI ID matching API limitation. This patch fixes that limitation with this patch that you see here, with a trivial one line fix, which does require your attention.
The other patches will go through my random.git tree naturally, but because those patches depend on this one here, in order to compile without warnings (and be functional at all), it would be nice if you would provide an "Acked-by" on it and permit me to /also/ take it through my random.git tree (if it looks like a correct patch to you, of course). This would make the merge logistics a lot easier. Plus it's a small +1/-1 line change.
Quoted 1 line
This v6 updates the commit message.
Quoted 24 lines
Please have a look and let me know what you think.
Thanks,
Jasoninclude/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/mod_devicetable.h +1
-2@@ -211,7 +211,7 @@ struct css_device_id {kernel_ulong_t driver_data; }; -#define ACPI_ID_LEN 9 +#define ACPI_ID_LEN 16struct acpi_device_id {__u8 id[ACPI_ID_LEN ]; --2.35.1
Re: [PATCH v5 2/3] ACPI: allow longer device IDs
In reply to Rafael J. WysockiHi,
Quoted 1 line · Rafael J. Wysocki
+Mika, Andy and Hans in case they have something to add
Thanks, I don't really have anything to add to the discussion on v6 of this patch.
Regards,
Hans
Quoted 53 lines · Jason A. Donenfeld
Quoted 29 lines
Hey again,
Quoted 14 lines · Jason A. Donenfeld
Hi Alex,
Quoted 9 lines · Alexander Graf
Quoted 3 lines
To allow device drivers to match identifiers that exceed the 9 byte limit, this simply ups the length to 16, just like it was before the aforementioned commit. Empirical testing indicates that this
This is only true for 64bit systems where padding automatically bloated to 9 byte array to 16. I still believe the patch is fine as it is, but there will be minor .rodata overhead on 32bit targets which you may want to quantify in the patch description.
Quoted 6 lines
Good point. So I just tried this out with a 32-bit i686 kernel and the results are the same again for the size of vmlinux. I then ran
objdump --headersand looked at the size of the .rodata section, where it's also the same. I'm not quite sure what to make of this, as it's not what I was expecting, but I think I tested it right. So maybe we're lucky here?I tried a little harder to get _some_ difference on 32-bit, and managed to get one by doing
i386_defconfigand then switching off modules to make all M into Y, and then compared sizes:Quoted 8 lines
vmlinux: 25590780 -> 25598972, so a 0.032% increase.
bzImage: 8698944 -> 8699424, so a 0.0055% increase.So it does increase, ever so slightly, but a) on 32-bit, and b) a super, super tiny amount.
In other words, I still think this patch is very much a-okay. But very eager to hear from Rafael on the approach.
Increasing the
ACPI_ID_LENvalue is fine with me, but the patch changelog is not entirely accurate.The ACPI subsystem uses struct
acpi_device_idmostly (if not only) for device ID matching and it is generally used for creating lists of ACPI device IDs in drivers (and allow/deny lists etc). The device IDs extracted from the ACPI tables can be longer thanACPI_ID_LEN.This means that drivers cannot match device IDs longer than 8 characters (excluding the terminating 0), because the IDs in the lists used by them for ID matching cannot be longer than this and not because the ACPI subsystem is limited by that value.
Jason A. Donenfeld
maintainerPATCH v5 3/3 virt: vmgenid: introduce driver for reinitializing RNG on VM fork
In reply to Jason A. DonenfeldVM Generation ID is a feature from Microsoft, described at
<https://go.microsoft.com/fwlink/?LinkId=260709>, and supported by Hyper-V and QEMU. Its usage is described in Microsoft's RNG whitepaper,
<https://aka.ms/win10rng>, as:
If the OS is running in a VM, there is a problem that most hypervisors can snapshot the state of the machine and later rewind the VM state to the saved state. This results in the machine running a second time with the exact same RNG state, which leads to serious security problems. To reduce the window of vulnerability, Windows 10 on a Hyper-V VM will detect when the VM state is reset, retrieve a unique (not random) value from the hypervisor, and reseed the root RNG with that unique value. This does not eliminate the vulnerability, but it greatly reduces the time during which the RNG system will produce the same outputs as it did during a previous instantiation of the same VM state.
Linux has the same issue, and given that vmgenid is supported already by multiple hypervisors, we can implement more or less the same solution. So this commit wires up the vmgenid ACPI notification to the RNG's newly added add_vmfork_randomness() function.
It can be used from qemu via the -device vmgenid,guid=auto parameter. After setting that, use savevm in the monitor to save the VM state, then quit QEMU, start it again, and use loadvm. That will trigger this driver's notify function, which hands the new UUID to the RNG. This is described in <https://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/vmgenid.txt>.
And there are hooks for this in libvirt as well, described in
<https://libvirt.org/formatdomain.html#general-metadata>.
Note, however, that the treatment of this as a UUID is considered to be an accidental QEMU nuance, per
<https://github.com/libguestfs/virt-v2v/blob/master/docs/vm-generation-id-across-hypervisors.txt>,
so this driver simply treats these bytes as an opaque 128-bit binary blob, as per the spec. This doesn't really make a difference anyway, considering that's how it ends up when handed to the RNG in the end.
---
Changes v4->v5:
- [Greg] Use module_acpi_driver instead of writing my own code.
- [Alex] Match on _CID instead of _HID.
- Prefer Y over M but still allow M, to handle initramfs reseeds.
- [Wei] Use IS_ERR instead of NULL check with devm_memremap.
MAINTAINERS | 1 + drivers/virt/Kconfig | 11 +++++ drivers/virt/Makefile | 1 + drivers/virt/vmgenid.c | 100 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 drivers/virt/vmgenid.c
MAINTAINERS +1 -0
@@ -16211,6 +16211,7 @@ M: Jason A. Donenfeld <[email protected]> T: git https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git S: Maintained F: drivers/char/random.c +F: drivers/virt/vmgenid.c RAPIDIO SUBSYSTEM M: Matt Porter <[email protected]>
drivers/virt/Kconfig +11 -0
@@ -13,6 +13,17 @@ menuconfig VIRT_DRIVERS if VIRT_DRIVERS +config VMGENID + tristate "Virtual Machine Generation ID driver" + default y + depends on ACPI + help + Say Y here to use the hypervisor-provided Virtual Machine Generation ID + to reseed the RNG when the VM is cloned. This is highly recommended if + you intend to do any rollback / cloning / snapshotting of VMs. + + Prefer Y to M so that this protection is activated very early. + config FSL_HV_MANAGER tristate "Freescale hypervisor management driver" depends on FSL_SOC
drivers/virt/Makefile +1 -0
@@ -4,6 +4,7 @@ # obj-$(CONFIG_FSL_HV_MANAGER) += fsl_hypervisor.o +obj-$(CONFIG_VMGENID) += vmgenid.o obj-y += vboxguest/ obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/
drivers/virt/vmgenid.c new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
2.35.1
RE: [PATCH v5 3/3] virt: vmgenid: introduce driver for reinitializing RNG on VM fork
From: Souradeep Chakrabarti <[email protected]>
Jason A. Donenfeld <[email protected]> Sent: Saturday, February 26, 2022 2:07 PM
Quoted 38 lines
VM Generation ID is a feature from Microsoft, described at
<https://go.microsoft.com/fwlink/?LinkId=260709>, and supported by Hyper-V and QEMU. Its usage is described in Microsoft's RNG whitepaper,
<https://aka.ms/win10rng>, as:If the OS is running in a VM, there is a problem that most hypervisors can snapshot the state of the machine and later rewind the VM state to the saved state. This results in the machine running a second time with the exact same RNG state, which leads to serious security problems. To reduce the window of vulnerability, Windows 10 on a Hyper-V VM will detect when the VM state is reset, retrieve a unique (not random) value from the hypervisor, and reseed the root RNG with that unique value. This does not eliminate the vulnerability, but it greatly reduces the time during which the RNG system will produce the same outputs as it did during a previous instantiation of the same VM state.
Linux has the same issue, and given that vmgenid is supported already by multiple hypervisors, we can implement more or less the same solution. So this commit wires up the vmgenid ACPI notification to the RNG's newly added
add_vmfork_randomness()function.It can be used from qemu via the
-device vmgenid,guid=autoparameter. After setting that, usesavevmin the monitor to save the VM state, then quit QEMU, start it again, and useloadvm. That will trigger this driver's notify function, which hands the new UUID to the RNG. This is described in <https://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/vmgenid.txt>.
And there are hooks for this in libvirt as well, described in
<https://libvirt.org/formatdomain.html#general-metadata>.Note, however, that the treatment of this as a UUID is considered to be an accidental QEMU nuance, per
<https://github.com/libguestfs/virt-v2v/blob/master/docs/vm-generation-id-across-hypervisors.txt>,
so this driver simply treats these bytes as an opaque 128-bit binary blob, as per the spec. This doesn't really make a difference anyway, considering that's how it ends up when handed to the RNG in the end.
Quoted 9 lines
Cc Alexander Graf <[email protected]>Cc Adrian Catangiu <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc Dominik Brodowski <[email protected]>Cc Wei Yongjun <[email protected]>Reviewed-by Ard Biesheuvel <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Laszlo Ersek <[email protected]>Signed-off-by Jason A. Donenfeld <[email protected]>
The patch has been successfully verified in Hyper-V. I have used checkpoint to create snapshot and restarted the VM multiple times from the same snapshot by applying it each time. To confirm the unique VM generation id, printk has been used to print the value each time.
Quoted 14 lines
---
Changesv4->v5:
- [Greg] Usemodule_acpi_driverinstead of writing my own code.
- [Alex] Match on_CIDinstead of_HID.
- Prefer Y over M but still allow M, to handle initramfs reseeds.
- [Wei] UseIS_ERRinstead of NULL check withdevm_memremap.MAINTAINERS | 1 + drivers/virt/Kconfig | 11 +++++ drivers/virt/Makefile | 1 + drivers/virt/vmgenid.c | 100 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 drivers/virt/vmgenid.c