2024-03-25 19:53:37

by Sudan Landge

[permalink] [raw]
Subject: [PATCH v3 0/4] virt: vmgenid: Add devicetree bindings support

This small series of patches aims to add devicetree bindings support for
the Virtual Machine Generation ID (vmgenid).

Virtual Machine Generation ID was introduced in commit af6b54e2b5ba
("virt: vmgenid: notify RNG of VM fork and supply generation ID") as an
ACPI only device.

VMGenID specification http://go.microsoft.com/fwlink/?LinkId=260709 defines
a mechanism for the BIOS/hypervisors to communicate to the virtual machine
that it is executed with a different configuration (e.g. snapshot execution
or creation from a template).
The guest operating system can use the notification for various purposes
such as re-initializing its random number generator etc.

More references to vmgenid specs:
- https://www.qemu.org/docs/master/specs/vmgenid.html
- https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/virtual-machine-generation-identifier

*Reason for this change*:
Chosing ACPI or devicetree is an intrinsic part of an hypervisor design.
Without going into details of why a hypervisor would chose DT over ACPI,
we would like to highlight that the hypervisors that have chose devicetree
and now want to make use of the vmgenid functionality cannot do so today
because vmgenid is an ACPI only device.
This forces these hypervisors to change their design which could have
undesirable impacts on their use-cases, test-scenarios etc.

The point of vmgenid is to provide a mechanism to discover a GUID when
the execution state of a virtual machine changes and the simplest
way to do it is pass a memory location and an interrupt via devicetree.
It would complicate things unnecessarily if instead of using devicetree,
we try to implement a new protocol or modify other protocols to somehow
provide the same functionility.

We believe that adding a devicetree binding for vmgenid is a simpler,
better alternative to provide the same functionality and will allow
such hypervisors as mentioned above to continue using devicetree.

Addtional notes:
While adding the devicetree support we considered re-using existing
structures/code to avoid duplication code and reduce maintenance; so,
we used the same driver to be configured either by ACPI or by DT.
This also meant reimplementing the existing vmgenid ACPI bus driver as a
platform driver and making it discoverable using `driver.of_match_table`
and `driver.acpi_match_table`.

There is no user impact or change in vmgenid functionality when used
with ACPI. We verified ACPI support of these patches on X86 and DT
support on ARM using Firecracker hypervisor
https://github.com/firecracker-microvm/firecracker.

To check schema and syntax errors, the bindings file is verified with:
```
make dt_binding_check \
DT_SCHEMA_FILES=Documentation/devicetree/bindings/vmgenid/vmgenid.yaml
```
and the patches were verified with:
`scripts/checkpatch.pl --strict v1-000*`.

Changelog with respect to version 2:
- As per review comments, used platform apis instead of "of_*" APIs,
removed unnecessary #include and used IF_ENABLED instead of ifdef.
- Added more info for vmgenid buffer address and corrected the formatting.
- Replaced the compatible string from "linux,*" to "virtual,*" because,
the device does not have a vendor.

Changelog with respect to version 1:
- Moved vmgenid.yaml bindings to the more related "rng" folder.
- Removed `vmgenid_remove` to since it is unrelated to the
current goal of the patch.
- Updated the cover letter and bindings commit
"[PATCH v2 3/4] dt-bindings: rng: Add vmgenid support" to
provide more information on vmgenid.
- Compiled with and without CONFIG_OF/CONFIG_ACPI and fixed
compilers errors/warnings.


Sudan Landge (4):
virt: vmgenid: rearrange code to make review easier
virt: vmgenid: change implementation to use a platform driver
dt-bindings: rng: Add vmgenid support
virt: vmgenid: add support for devicetree bindings

.../devicetree/bindings/rng/vmgenid.yaml | 58 ++++++
MAINTAINERS | 1 +
drivers/virt/Kconfig | 1 -
drivers/virt/vmgenid.c | 194 ++++++++++++++----
4 files changed, 217 insertions(+), 37 deletions(-)
create mode 100644 Documentation/devicetree/bindings/rng/vmgenid.yaml


base-commit: 8e938e39866920ddc266898e6ae1fffc5c8f51aa
--
2.40.1




2024-03-25 19:53:53

by Sudan Landge

[permalink] [raw]
Subject: [PATCH v3 1/4] virt: vmgenid: rearrange code to make review easier

Rearrage the functions of vmgenid to make the next commit,
which re-implements vmgenid as a platform driver, easier to review.

Signed-off-by: Sudan Landge <[email protected]>
---
drivers/virt/vmgenid.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c
index b67a28da4702..ea956df02874 100644
--- a/drivers/virt/vmgenid.c
+++ b/drivers/virt/vmgenid.c
@@ -21,6 +21,20 @@ struct vmgenid_state {
u8 this_id[VMGENID_SIZE];
};

+static void vmgenid_notify(struct acpi_device *device, u32 event)
+{
+ struct vmgenid_state *state = acpi_driver_data(device);
+ char *envp[] = { "NEW_VMGENID=1", NULL };
+ u8 old_id[VMGENID_SIZE];
+
+ memcpy(old_id, state->this_id, sizeof(old_id));
+ memcpy(state->this_id, state->next_id, sizeof(state->this_id));
+ if (!memcmp(old_id, state->this_id, sizeof(old_id)))
+ return;
+ add_vmfork_randomness(state->this_id, sizeof(state->this_id));
+ kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp);
+}
+
static int vmgenid_add(struct acpi_device *device)
{
struct acpi_buffer parsed = { ACPI_ALLOCATE_BUFFER };
@@ -65,20 +79,6 @@ static int vmgenid_add(struct acpi_device *device)
return ret;
}

-static void vmgenid_notify(struct acpi_device *device, u32 event)
-{
- struct vmgenid_state *state = acpi_driver_data(device);
- char *envp[] = { "NEW_VMGENID=1", NULL };
- u8 old_id[VMGENID_SIZE];
-
- memcpy(old_id, state->this_id, sizeof(old_id));
- memcpy(state->this_id, state->next_id, sizeof(state->this_id));
- if (!memcmp(old_id, state->this_id, sizeof(old_id)))
- return;
- add_vmfork_randomness(state->this_id, sizeof(state->this_id));
- kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp);
-}
-
static const struct acpi_device_id vmgenid_ids[] = {
{ "VMGENCTR", 0 },
{ "VM_GEN_COUNTER", 0 },
--
2.40.1



2024-03-25 19:54:07

by Sudan Landge

[permalink] [raw]
Subject: [PATCH v3 2/4] virt: vmgenid: change implementation to use a platform driver

Re-implement vmgenid as a platform driver in preparation
for adding devicetree bindings support in next commits.

Signed-off-by: Sudan Landge <[email protected]>
---
drivers/virt/vmgenid.c | 101 ++++++++++++++++++++++++++++++-----------
1 file changed, 74 insertions(+), 27 deletions(-)

diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c
index ea956df02874..d5394c706bd9 100644
--- a/drivers/virt/vmgenid.c
+++ b/drivers/virt/vmgenid.c
@@ -11,6 +11,8 @@
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/random.h>
+#include <acpi/actypes.h>
+#include <linux/platform_device.h>

ACPI_MODULE_NAME("vmgenid");

@@ -21,9 +23,9 @@ struct vmgenid_state {
u8 this_id[VMGENID_SIZE];
};

-static void vmgenid_notify(struct acpi_device *device, u32 event)
+static void vmgenid_notify(struct device *device)
{
- struct vmgenid_state *state = acpi_driver_data(device);
+ struct vmgenid_state *state = device->driver_data;
char *envp[] = { "NEW_VMGENID=1", NULL };
u8 old_id[VMGENID_SIZE];

@@ -32,22 +34,34 @@ static void vmgenid_notify(struct acpi_device *device, u32 event)
if (!memcmp(old_id, state->this_id, sizeof(old_id)))
return;
add_vmfork_randomness(state->this_id, sizeof(state->this_id));
- kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp);
+ kobject_uevent_env(&device->kobj, KOBJ_CHANGE, envp);
}

-static int vmgenid_add(struct acpi_device *device)
+static void vmgenid_acpi_handler(acpi_handle handle, u32 event, void *dev)
{
+ vmgenid_notify(dev);
+}
+
+static int setup_vmgenid_state(struct vmgenid_state *state, u8 *next_id)
+{
+ if (IS_ERR(next_id))
+ return PTR_ERR(next_id);
+
+ state->next_id = next_id;
+ memcpy(state->this_id, state->next_id, sizeof(state->this_id));
+ add_device_randomness(state->this_id, sizeof(state->this_id));
+ return 0;
+}
+
+static int vmgenid_add_acpi(struct device *dev, struct vmgenid_state *state)
+{
+ struct acpi_device *device = ACPI_COMPANION(dev);
struct acpi_buffer parsed = { ACPI_ALLOCATE_BUFFER };
- struct vmgenid_state *state;
union acpi_object *obj;
phys_addr_t phys_addr;
acpi_status status;
int ret = 0;

- state = devm_kmalloc(&device->dev, sizeof(*state), GFP_KERNEL);
- if (!state)
- return -ENOMEM;
-
status = acpi_evaluate_object(device->handle, "ADDR", NULL, &parsed);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating ADDR"));
@@ -63,19 +77,42 @@ static int vmgenid_add(struct acpi_device *device)

phys_addr = (obj->package.elements[0].integer.value << 0) |
(obj->package.elements[1].integer.value << 32);
- state->next_id = devm_memremap(&device->dev, phys_addr, VMGENID_SIZE, MEMREMAP_WB);
- if (IS_ERR(state->next_id)) {
- ret = PTR_ERR(state->next_id);
+
+ ret = setup_vmgenid_state(state,
+ (u8 *)devm_memremap(&device->dev, phys_addr,
+ VMGENID_SIZE, MEMREMAP_WB));
+ if (ret)
+ goto out;
+
+ dev->driver_data = state;
+ status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
+ vmgenid_acpi_handler, dev);
+ if (ACPI_FAILURE(status)) {
+ dev_err(dev, "Failed to install acpi notify handler");
+ ret = -ENODEV;
+ dev->driver_data = NULL;
goto out;
}
+out:
+ ACPI_FREE(parsed.pointer);
+ return ret;
+}

- memcpy(state->this_id, state->next_id, sizeof(state->this_id));
- add_device_randomness(state->this_id, sizeof(state->this_id));
+static int vmgenid_add(struct platform_device *pdev)
+{
+ struct vmgenid_state *state;
+ struct device *dev = &pdev->dev;
+ int ret = 0;

- device->driver_data = state;
+ state = devm_kmalloc(dev, sizeof(*state), GFP_KERNEL);
+ if (!state)
+ return -ENOMEM;
+
+ ret = vmgenid_add_acpi(dev, state);
+
+ if (ret)
+ devm_kfree(dev, state);

-out:
- ACPI_FREE(parsed.pointer);
return ret;
}

@@ -84,20 +121,30 @@ static const struct acpi_device_id vmgenid_ids[] = {
{ "VM_GEN_COUNTER", 0 },
{ }
};
+MODULE_DEVICE_TABLE(acpi, vmgenid_ids);

-static struct acpi_driver vmgenid_driver = {
- .name = "vmgenid",
- .ids = vmgenid_ids,
- .owner = THIS_MODULE,
- .ops = {
- .add = vmgenid_add,
- .notify = vmgenid_notify
- }
+static struct platform_driver vmgenid_plaform_driver = {
+ .probe = vmgenid_add,
+ .driver = {
+ .name = "vmgenid",
+ .acpi_match_table = ACPI_PTR(vmgenid_ids),
+ .owner = THIS_MODULE,
+ },
};

-module_acpi_driver(vmgenid_driver);
+static int vmgenid_platform_device_init(void)
+{
+ return platform_driver_register(&vmgenid_plaform_driver);
+}
+
+static void vmgenid_platform_device_exit(void)
+{
+ platform_driver_unregister(&vmgenid_plaform_driver);
+}
+
+module_init(vmgenid_platform_device_init)
+module_exit(vmgenid_platform_device_exit)

-MODULE_DEVICE_TABLE(acpi, vmgenid_ids);
MODULE_DESCRIPTION("Virtual Machine Generation ID");
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Jason A. Donenfeld <[email protected]>");
--
2.40.1



2024-03-25 19:54:29

by Sudan Landge

[permalink] [raw]
Subject: [PATCH v3 3/4] dt-bindings: rng: Add vmgenid support

Virtual Machine Generation ID driver was introduced in commit af6b54e2b5ba
("virt: vmgenid: notify RNG of VM fork and supply generation ID"), as an
ACPI only device.

VMGenID specification http://go.microsoft.com/fwlink/?LinkId=260709 defines
a mechanism for the BIOS/hypervisors to communicate to the virtual machine
that it is executed with a different configuration (e.g. snapshot execution
or creation from a template).
The guest operating system can use the notification for various purposes
such as re-initializing its random number generator etc.

As per the specs, hypervisor should provide a globally unique identified,
or GUID via ACPI.

This patch tries to mimic the mechanism to provide the same functionality
which is for a hypervisor/BIOS to notify the virtual machine when it is
executed with a different configuration.

As part of this support the devicetree bindings requires the hypervisors or
BIOS to provide a memory address which holds the GUID and an IRQ which is
used to notify when there is a change in the GUID.
The memory exposed in the DT should follow the rules defined in the
vmgenid spec mentioned above.

*Reason for this change*:
Chosing ACPI or devicetree is an intrinsic part of an hypervisor design.
Without going into details of why a hypervisor would chose DT over ACPI,
we would like to highlight that the hypervisors that have chose devicetree
and now want to make use of the vmgenid functionality cannot do so today
because vmgenid is an ACPI only device.
This forces these hypervisors to change their design which could have
undesirable impacts on their use-cases, test-scenarios etc.

The point of vmgenid is to provide a mechanism to discover a GUID when
the execution state of a virtual machine changes and the simplest
way to do it is pass a memory location and an interrupt via devicetree.
It would complicate things unnecessarily if instead of using devicetree,
we try to implement a new protocol or modify other protocols to somehow
provide the same functionility.

We believe that adding a devicetree binding for vmgenid is a simpler,
better alternative to provide the same functionality and will allow
such hypervisors as mentioned above to continue using devicetree.

More references to vmgenid specs:
- https://www.qemu.org/docs/master/specs/vmgenid.html
- https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/virtual-
machine-generation-identifier

Signed-off-by: Sudan Landge <[email protected]>
---
.../devicetree/bindings/rng/vmgenid.yaml | 58 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 59 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rng/vmgenid.yaml

diff --git a/Documentation/devicetree/bindings/rng/vmgenid.yaml b/Documentation/devicetree/bindings/rng/vmgenid.yaml
new file mode 100644
index 000000000000..24643080d6b0
--- /dev/null
+++ b/Documentation/devicetree/bindings/rng/vmgenid.yaml
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/rng/vmgenid.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Virtual Machine Generation Counter ID device
+
+maintainers:
+ - Jason A. Donenfeld <[email protected]>
+
+description:
+ Firmwares or hypervisors can use this devicetree to describe
+ interrupts and the shared resources to inject a Virtual Machine Generation
+ counter.
+
+properties:
+ compatible:
+ const: virtual,vmgenctr
+
+ "#interrupt-cells":
+ const: 3
+ description:
+ The 1st cell is the interrupt type.
+ The 2nd cell contains the interrupt number for the interrupt type.
+ The 3rd cell is for trigger type and level flags.
+
+ interrupt-map: true
+
+ reg:
+ description:
+ The 1st cell specifies the base physical address of the 8-byte aligned
+ buffer in guest memory space which is guaranteed not to be used by the
+ operating system.
+ The 2nd cell specifies the size of the buffer which holds the VMGenID.
+ maxItems: 1
+
+ interrupts:
+ description:
+ interrupt used to notify that a new VMGenID counter is available.
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ rng@80000000 {
+ compatible = "virtual,vmgenctr";
+ reg = <0x80000000 0x1000>;
+ interrupts = <0x00 0x23 0x01>;
+ };
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index de6a64b248ae..e295d2f50af4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18461,6 +18461,7 @@ M: "Theodore Ts'o" <[email protected]>
M: Jason A. Donenfeld <[email protected]>
S: Maintained
T: git https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git
+F: Documentation/devicetree/bindings/rng/vmgenid.yaml
F: drivers/char/random.c
F: drivers/virt/vmgenid.c

--
2.40.1



2024-03-25 20:54:27

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] dt-bindings: rng: Add vmgenid support

On Mon, Mar 25, 2024 at 2:53 PM Sudan Landge <[email protected]> wrote:
>

Please give time for discussions on prior versions to finish and
others to comment. We're not all in one timezone and are busy. I've
replied there too.

> Virtual Machine Generation ID driver was introduced in commit af6b54e2b5ba
> ("virt: vmgenid: notify RNG of VM fork and supply generation ID"), as an
> ACPI only device.
>
> VMGenID specification http://go.microsoft.com/fwlink/?LinkId=260709 defines
> a mechanism for the BIOS/hypervisors to communicate to the virtual machine
> that it is executed with a different configuration (e.g. snapshot execution
> or creation from a template).
> The guest operating system can use the notification for various purposes
> such as re-initializing its random number generator etc.
>
> As per the specs, hypervisor should provide a globally unique identified,
> or GUID via ACPI.
>
> This patch tries to mimic the mechanism to provide the same functionality
> which is for a hypervisor/BIOS to notify the virtual machine when it is
> executed with a different configuration.
>
> As part of this support the devicetree bindings requires the hypervisors or
> BIOS to provide a memory address which holds the GUID and an IRQ which is
> used to notify when there is a change in the GUID.
> The memory exposed in the DT should follow the rules defined in the
> vmgenid spec mentioned above.
>
> *Reason for this change*:
> Chosing ACPI or devicetree is an intrinsic part of an hypervisor design.
> Without going into details of why a hypervisor would chose DT over ACPI,
> we would like to highlight that the hypervisors that have chose devicetree
> and now want to make use of the vmgenid functionality cannot do so today
> because vmgenid is an ACPI only device.
> This forces these hypervisors to change their design which could have
> undesirable impacts on their use-cases, test-scenarios etc.
>
> The point of vmgenid is to provide a mechanism to discover a GUID when
> the execution state of a virtual machine changes and the simplest
> way to do it is pass a memory location and an interrupt via devicetree.
> It would complicate things unnecessarily if instead of using devicetree,
> we try to implement a new protocol or modify other protocols to somehow
> provide the same functionility.
>
> We believe that adding a devicetree binding for vmgenid is a simpler,
> better alternative to provide the same functionality and will allow
> such hypervisors as mentioned above to continue using devicetree.
>
> More references to vmgenid specs:
> - https://www.qemu.org/docs/master/specs/vmgenid.html
> - https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/virtual-
> machine-generation-identifier
>
> Signed-off-by: Sudan Landge <[email protected]>
> ---
> .../devicetree/bindings/rng/vmgenid.yaml | 58 +++++++++++++++++++

Filename should match the compatible, whatever that ends up being.

> MAINTAINERS | 1 +
> 2 files changed, 59 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rng/vmgenid.yaml
>
> diff --git a/Documentation/devicetree/bindings/rng/vmgenid.yaml b/Documentation/devicetree/bindings/rng/vmgenid.yaml
> new file mode 100644
> index 000000000000..24643080d6b0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rng/vmgenid.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/rng/vmgenid.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Virtual Machine Generation Counter ID device
> +
> +maintainers:
> + - Jason A. Donenfeld <[email protected]>
> +
> +description:
> + Firmwares or hypervisors can use this devicetree to describe
> + interrupts and the shared resources to inject a Virtual Machine Generation
> + counter.
> +
> +properties:
> + compatible:
> + const: virtual,vmgenctr
> +
> +
> + "#interrupt-cells":
> + const: 3
> + description:
> + The 1st cell is the interrupt type.
> + The 2nd cell contains the interrupt number for the interrupt type.
> + The 3rd cell is for trigger type and level flags.
> +
> + interrupt-map: true

Sigh. What makes this an interrupt-map? Why do you think you need this
and #interrupt-cells? You don't have them in the example.

> +
> + reg:
> + description:
> + The 1st cell specifies the base physical address of the 8-byte aligned
> + buffer in guest memory space which is guaranteed not to be used by the
> + operating system.
> + The 2nd cell specifies the size of the buffer which holds the VMGenID.

I didn't ask for you to explain the purpose of cells in 'reg' as that
is the same for *every* instance of 'reg'. Ignore DTisms and describe
the format of the registers. For example, is it 4 32-bit registers
(hex) or 9 32-bit registers (ascii)?

> + maxItems: 1
> +
> + interrupts:
> + description:
> + interrupt used to notify that a new VMGenID counter is available.
> + maxItems: 1
> +
> +required:
> + - compatible
> + - reg
> + - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + rng@80000000 {
> + compatible = "virtual,vmgenctr";
> + reg = <0x80000000 0x1000>;
> + interrupts = <0x00 0x23 0x01>;
> + };
> +
> +...
> diff --git a/MAINTAINERS b/MAINTAINERS
> index de6a64b248ae..e295d2f50af4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18461,6 +18461,7 @@ M: "Theodore Ts'o" <[email protected]>
> M: Jason A. Donenfeld <[email protected]>
> S: Maintained
> T: git https://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git
> +F: Documentation/devicetree/bindings/rng/vmgenid.yaml
> F: drivers/char/random.c
> F: drivers/virt/vmgenid.c
>
> --
> 2.40.1
>
>

2024-03-25 21:54:14

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 2/4] virt: vmgenid: change implementation to use a platform driver

On 25/03/2024 20:53, Sudan Landge wrote:
> Re-implement vmgenid as a platform driver in preparation
> for adding devicetree bindings support in next commits.
>
> Signed-off-by: Sudan Landge <[email protected]>
> ---
> drivers/virt/vmgenid.c | 101 ++++++++++++++++++++++++++++++-----------
> 1 file changed, 74 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c
> index ea956df02874..d5394c706bd9 100644
> --- a/drivers/virt/vmgenid.c
> +++ b/drivers/virt/vmgenid.c
> @@ -11,6 +11,8 @@
> #include <linux/module.h>
> #include <linux/acpi.h>
> #include <linux/random.h>
> +#include <acpi/actypes.h>
> +#include <linux/platform_device.h>

Do not add headers to the end of lists.

>
> ACPI_MODULE_NAME("vmgenid");
>

..

>
> -static struct acpi_driver vmgenid_driver = {
> - .name = "vmgenid",
> - .ids = vmgenid_ids,
> - .owner = THIS_MODULE,
> - .ops = {
> - .add = vmgenid_add,
> - .notify = vmgenid_notify
> - }
> +static struct platform_driver vmgenid_plaform_driver = {
> + .probe = vmgenid_add,
> + .driver = {
> + .name = "vmgenid",
> + .acpi_match_table = ACPI_PTR(vmgenid_ids),

ACPI_PTR does not make sense. If this can be compile tested !ACPI, then
this is wrong. If this cannot be compile tested, then this is redundant
and confusing so... also wrong.

> + .owner = THIS_MODULE,
> + },
> };
>
> -module_acpi_driver(vmgenid_driver);
> +static int vmgenid_platform_device_init(void)
> +{
> + return platform_driver_register(&vmgenid_plaform_driver);
> +}
> +
> +static void vmgenid_platform_device_exit(void)
> +{
> + platform_driver_unregister(&vmgenid_plaform_driver);
> +}
> +
> +module_init(vmgenid_platform_device_init)
> +module_exit(vmgenid_platform_device_exit)

Why this cannot be module_platform_driver?



Best regards,
Krzysztof


2024-03-25 21:59:57

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 3/4] dt-bindings: rng: Add vmgenid support

On 25/03/2024 20:53, Sudan Landge wrote:
> Virtual Machine Generation ID driver was introduced in commit af6b54e2b5ba
> ("virt: vmgenid: notify RNG of VM fork and supply generation ID"), as an
> ACPI only device.

..


> diff --git a/Documentation/devicetree/bindings/rng/vmgenid.yaml b/Documentation/devicetree/bindings/rng/vmgenid.yaml
> new file mode 100644
> index 000000000000..24643080d6b0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rng/vmgenid.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/rng/vmgenid.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Virtual Machine Generation Counter ID device
> +
> +maintainers:
> + - Jason A. Donenfeld <[email protected]>
> +
> +description:
> + Firmwares or hypervisors can use this devicetree to describe
> + interrupts and the shared resources to inject a Virtual Machine Generation
> + counter.
> +
> +properties:
> + compatible:
> + const: virtual,vmgenctr
> +
> + "#interrupt-cells":
> + const: 3
> + description:
> + The 1st cell is the interrupt type.
> + The 2nd cell contains the interrupt number for the interrupt type.
> + The 3rd cell is for trigger type and level flags.

How is this interrupt-controller now? You already got such comment on v2.

> +
> + interrupt-map: true
> +
> + reg:
> + description:
> + The 1st cell specifies the base physical address of the 8-byte aligned
> + buffer in guest memory space which is guaranteed not to be used by the
> + operating system.
> + The 2nd cell specifies the size of the buffer which holds the VMGenID.
> + maxItems: 1
> +
> + interrupts:
> + description:
> + interrupt used to notify that a new VMGenID counter is available.
> + maxItems: 1
> +
> +required:
> + - compatible
> + - reg
> + - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + rng@80000000 {
> + compatible = "virtual,vmgenctr";
> + reg = <0x80000000 0x1000>;
> + interrupts = <0x00 0x23 0x01>;

Use standard defines and drop padding from hex numbers. Or just use
decimal numbers because hex is anyway unusual, unless this is what your
device datasheet says.

And what is 0x00 in the interrupt?

Best regards,
Krzysztof


2024-03-26 01:05:45

by Sudan Landge

[permalink] [raw]
Subject: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings

- Extend the vmgenid platform driver to support devicetree bindings.
With this support, hypervisors can send vmgenid notifications to
the virtual machine without the need to enable ACPI. The bindings
are located at: Documentation/devicetree/bindings/rng/vmgenid.yaml

- Use proper FLAGS to compile with and without ACPI and/or devicetree.

Signed-off-by: Sudan Landge <[email protected]>
---
drivers/virt/Kconfig | 1 -
drivers/virt/vmgenid.c | 85 +++++++++++++++++++++++++++++++++++++++---
2 files changed, 80 insertions(+), 6 deletions(-)

diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig
index 40129b6f0eca..d8c848cf09a6 100644
--- a/drivers/virt/Kconfig
+++ b/drivers/virt/Kconfig
@@ -16,7 +16,6 @@ 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
diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c
index d5394c706bd9..a648465bea43 100644
--- a/drivers/virt/vmgenid.c
+++ b/drivers/virt/vmgenid.c
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2022 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
*
- * The "Virtual Machine Generation ID" is exposed via ACPI and changes when a
+ * The "Virtual Machine Generation ID" is exposed via ACPI or DT and changes when a
* virtual machine forks or is cloned. This driver exists for shepherding that
* information to random.c.
*/
@@ -21,6 +21,7 @@ enum { VMGENID_SIZE = 16 };
struct vmgenid_state {
u8 *next_id;
u8 this_id[VMGENID_SIZE];
+ unsigned int irq;
};

static void vmgenid_notify(struct device *device)
@@ -37,10 +38,24 @@ static void vmgenid_notify(struct device *device)
kobject_uevent_env(&device->kobj, KOBJ_CHANGE, envp);
}

+#if IS_ENABLED(CONFIG_ACPI)
static void vmgenid_acpi_handler(acpi_handle handle, u32 event, void *dev)
{
+ (void)handle;
+ (void)event;
vmgenid_notify(dev);
}
+#endif
+
+#if IS_ENABLED(CONFIG_OF)
+static irqreturn_t vmgenid_of_irq_handler(int irq, void *dev)
+{
+ (void)irq;
+ vmgenid_notify(dev);
+
+ return IRQ_HANDLED;
+}
+#endif

static int setup_vmgenid_state(struct vmgenid_state *state, u8 *next_id)
{
@@ -55,6 +70,7 @@ static int setup_vmgenid_state(struct vmgenid_state *state, u8 *next_id)

static int vmgenid_add_acpi(struct device *dev, struct vmgenid_state *state)
{
+#if IS_ENABLED(CONFIG_ACPI)
struct acpi_device *device = ACPI_COMPANION(dev);
struct acpi_buffer parsed = { ACPI_ALLOCATE_BUFFER };
union acpi_object *obj;
@@ -96,6 +112,49 @@ static int vmgenid_add_acpi(struct device *dev, struct vmgenid_state *state)
out:
ACPI_FREE(parsed.pointer);
return ret;
+#else
+ (void)dev;
+ (void)state;
+ return -EINVAL;
+#endif
+}
+
+static int vmgenid_add_of(struct platform_device *pdev, struct vmgenid_state *state)
+{
+#if IS_ENABLED(CONFIG_OF)
+ void __iomem *remapped_ptr;
+ int ret = 0;
+
+ remapped_ptr = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
+ if (IS_ERR(remapped_ptr)) {
+ ret = PTR_ERR(remapped_ptr);
+ goto out;
+ }
+
+ ret = setup_vmgenid_state(state, remapped_ptr);
+ if (ret)
+ goto out;
+
+ state->irq = platform_get_irq(pdev, 0);
+ if (state->irq < 0) {
+ ret = state->irq;
+ goto out;
+ }
+ pdev->dev.driver_data = state;
+
+ ret = devm_request_irq(&pdev->dev, state->irq,
+ vmgenid_of_irq_handler,
+ IRQF_SHARED, "vmgenid", &pdev->dev);
+ if (ret)
+ pdev->dev.driver_data = NULL;
+
+out:
+ return ret;
+#else
+ (void)dev;
+ (void)state;
+ return -EINVAL;
+#endif
}

static int vmgenid_add(struct platform_device *pdev)
@@ -108,7 +167,10 @@ static int vmgenid_add(struct platform_device *pdev)
if (!state)
return -ENOMEM;

- ret = vmgenid_add_acpi(dev, state);
+ if (dev->of_node)
+ ret = vmgenid_add_of(pdev, state);
+ else
+ ret = vmgenid_add_acpi(dev, state);

if (ret)
devm_kfree(dev, state);
@@ -116,18 +178,31 @@ static int vmgenid_add(struct platform_device *pdev)
return ret;
}

-static const struct acpi_device_id vmgenid_ids[] = {
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id vmgenid_of_ids[] = {
+ { .compatible = "linux,vmgenctr", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, vmgenid_of_ids);
+#endif
+
+#if IS_ENABLED(CONFIG_ACPI)
+static const struct acpi_device_id vmgenid_acpi_ids[] = {
{ "VMGENCTR", 0 },
{ "VM_GEN_COUNTER", 0 },
{ }
};
-MODULE_DEVICE_TABLE(acpi, vmgenid_ids);
+MODULE_DEVICE_TABLE(acpi, vmgenid_acpi_ids);
+#endif

static struct platform_driver vmgenid_plaform_driver = {
.probe = vmgenid_add,
.driver = {
.name = "vmgenid",
- .acpi_match_table = ACPI_PTR(vmgenid_ids),
+ .acpi_match_table = ACPI_PTR(vmgenid_acpi_ids),
+#if IS_ENABLED(CONFIG_OF)
+ .of_match_table = vmgenid_of_ids,
+#endif
.owner = THIS_MODULE,
},
};
--
2.40.1



2024-03-26 12:48:59

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings

Hi Sudan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 8e938e39866920ddc266898e6ae1fffc5c8f51aa]

url: https://github.com/intel-lab-lkp/linux/commits/Sudan-Landge/virt-vmgenid-rearrange-code-to-make-review-easier/20240326-035657
base: 8e938e39866920ddc266898e6ae1fffc5c8f51aa
patch link: https://lore.kernel.org/r/20240325195306.13133-5-sudanl%40amazon.com
patch subject: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings
config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240326/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240326/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/virt/vmgenid.c: In function 'vmgenid_add_of':
>> drivers/virt/vmgenid.c:154:15: error: 'dev' undeclared (first use in this function); did you mean 'pdev'?
154 | (void)dev;
| ^~~
| pdev
drivers/virt/vmgenid.c:154:15: note: each undeclared identifier is reported only once for each function it appears in


vim +154 drivers/virt/vmgenid.c

121
122 static int vmgenid_add_of(struct platform_device *pdev, struct vmgenid_state *state)
123 {
124 #if IS_ENABLED(CONFIG_OF)
125 void __iomem *remapped_ptr;
126 int ret = 0;
127
128 remapped_ptr = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
129 if (IS_ERR(remapped_ptr)) {
130 ret = PTR_ERR(remapped_ptr);
131 goto out;
132 }
133
134 ret = setup_vmgenid_state(state, remapped_ptr);
135 if (ret)
136 goto out;
137
138 state->irq = platform_get_irq(pdev, 0);
139 if (state->irq < 0) {
140 ret = state->irq;
141 goto out;
142 }
143 pdev->dev.driver_data = state;
144
145 ret = devm_request_irq(&pdev->dev, state->irq,
146 vmgenid_of_irq_handler,
147 IRQF_SHARED, "vmgenid", &pdev->dev);
148 if (ret)
149 pdev->dev.driver_data = NULL;
150
151 out:
152 return ret;
153 #else
> 154 (void)dev;
155 (void)state;
156 return -EINVAL;
157 #endif
158 }
159

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-03-26 12:53:22

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings

On 26/03/2024 13:48, kernel test robot wrote:
> Hi Sudan,
>
> kernel test robot noticed the following build errors:

..

> 134 ret = setup_vmgenid_state(state, remapped_ptr);
> 135 if (ret)
> 136 goto out;
> 137
> 138 state->irq = platform_get_irq(pdev, 0);
> 139 if (state->irq < 0) {
> 140 ret = state->irq;
> 141 goto out;
> 142 }
> 143 pdev->dev.driver_data = state;
> 144
> 145 ret = devm_request_irq(&pdev->dev, state->irq,
> 146 vmgenid_of_irq_handler,
> 147 IRQF_SHARED, "vmgenid", &pdev->dev);
> 148 if (ret)
> 149 pdev->dev.driver_data = NULL;
> 150
> 151 out:
> 152 return ret;
> 153 #else
> > 154 (void)dev;

So this code was not even built...

Best regards,
Krzysztof


2024-03-26 14:12:07

by Landge, Sudan

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings



On 26/03/2024 12:53, Krzysztof Kozlowski wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
>
>
>
> On 26/03/2024 13:48, kernel test robot wrote:
>> Hi Sudan,
>>
>> kernel test robot noticed the following build errors:
>
> ...
>
>> 134 ret = setup_vmgenid_state(state, remapped_ptr);
>> 135 if (ret)
>> 136 goto out;
>> 137
>> 138 state->irq = platform_get_irq(pdev, 0);
>> 139 if (state->irq < 0) {
>> 140 ret = state->irq;
>> 141 goto out;
>> 142 }
>> 143 pdev->dev.driver_data = state;
>> 144
>> 145 ret = devm_request_irq(&pdev->dev, state->irq,
>> 146 vmgenid_of_irq_handler,
>> 147 IRQF_SHARED, "vmgenid", &pdev->dev);
>> 148 if (ret)
>> 149 pdev->dev.driver_data = NULL;
>> 150
>> 151 out:
>> 152 return ret;
>> 153 #else
>> > 154 (void)dev;
>
> So this code was not even built...
>
> Best regards,
> Krzysztof
>
I built it with CONFIG_ACPI and CONFIG_OF enabled but missed to build it
without the CONFIG_OF flag. As mentioned in the other mail I'll make
sure to run all required tools and check for all combinations before
posting future patches.

2024-03-26 15:25:03

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings

Hi Sudan,

kernel test robot noticed the following build errors:

[auto build test ERROR on 8e938e39866920ddc266898e6ae1fffc5c8f51aa]

url: https://github.com/intel-lab-lkp/linux/commits/Sudan-Landge/virt-vmgenid-rearrange-code-to-make-review-easier/20240326-035657
base: 8e938e39866920ddc266898e6ae1fffc5c8f51aa
patch link: https://lore.kernel.org/r/20240325195306.13133-5-sudanl%40amazon.com
patch subject: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings
config: x86_64-randconfig-161-20240326 (https://download.01.org/0day-ci/archive/20240326/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240326/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/virt/vmgenid.c:154:8: error: use of undeclared identifier 'dev'
154 | (void)dev;
| ^
1 error generated.


vim +/dev +154 drivers/virt/vmgenid.c

121
122 static int vmgenid_add_of(struct platform_device *pdev, struct vmgenid_state *state)
123 {
124 #if IS_ENABLED(CONFIG_OF)
125 void __iomem *remapped_ptr;
126 int ret = 0;
127
128 remapped_ptr = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
129 if (IS_ERR(remapped_ptr)) {
130 ret = PTR_ERR(remapped_ptr);
131 goto out;
132 }
133
134 ret = setup_vmgenid_state(state, remapped_ptr);
135 if (ret)
136 goto out;
137
138 state->irq = platform_get_irq(pdev, 0);
139 if (state->irq < 0) {
140 ret = state->irq;
141 goto out;
142 }
143 pdev->dev.driver_data = state;
144
145 ret = devm_request_irq(&pdev->dev, state->irq,
146 vmgenid_of_irq_handler,
147 IRQF_SHARED, "vmgenid", &pdev->dev);
148 if (ret)
149 pdev->dev.driver_data = NULL;
150
151 out:
152 return ret;
153 #else
> 154 (void)dev;
155 (void)state;
156 return -EINVAL;
157 #endif
158 }
159

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-03-26 16:47:13

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings

Hi Sudan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 8e938e39866920ddc266898e6ae1fffc5c8f51aa]

url: https://github.com/intel-lab-lkp/linux/commits/Sudan-Landge/virt-vmgenid-rearrange-code-to-make-review-easier/20240326-035657
base: 8e938e39866920ddc266898e6ae1fffc5c8f51aa
patch link: https://lore.kernel.org/r/20240325195306.13133-5-sudanl%40amazon.com
patch subject: [PATCH v3 4/4] virt: vmgenid: add support for devicetree bindings
config: x86_64-buildonly-randconfig-004-20240326 (https://download.01.org/0day-ci/archive/20240327/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240327/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/virt/vmgenid.c: In function 'vmgenid_add_of':
drivers/virt/vmgenid.c:154:15: error: 'dev' undeclared (first use in this function); did you mean 'pdev'?
154 | (void)dev;
| ^~~
| pdev
drivers/virt/vmgenid.c:154:15: note: each undeclared identifier is reported only once for each function it appears in
drivers/virt/vmgenid.c: At top level:
>> drivers/virt/vmgenid.c:60:12: warning: 'setup_vmgenid_state' defined but not used [-Wunused-function]
60 | static int setup_vmgenid_state(struct vmgenid_state *state, u8 *next_id)
| ^~~~~~~~~~~~~~~~~~~
>> drivers/virt/vmgenid.c:27:13: warning: 'vmgenid_notify' defined but not used [-Wunused-function]
27 | static void vmgenid_notify(struct device *device)
| ^~~~~~~~~~~~~~


vim +/setup_vmgenid_state +60 drivers/virt/vmgenid.c

af6b54e2b5baa5 Jason A. Donenfeld 2022-02-23 26
fba2c3554a30ca Sudan Landge 2024-03-25 @27 static void vmgenid_notify(struct device *device)
5eb78dfcd888d3 Sudan Landge 2024-03-25 28 {
fba2c3554a30ca Sudan Landge 2024-03-25 29 struct vmgenid_state *state = device->driver_data;
5eb78dfcd888d3 Sudan Landge 2024-03-25 30 char *envp[] = { "NEW_VMGENID=1", NULL };
5eb78dfcd888d3 Sudan Landge 2024-03-25 31 u8 old_id[VMGENID_SIZE];
5eb78dfcd888d3 Sudan Landge 2024-03-25 32
5eb78dfcd888d3 Sudan Landge 2024-03-25 33 memcpy(old_id, state->this_id, sizeof(old_id));
5eb78dfcd888d3 Sudan Landge 2024-03-25 34 memcpy(state->this_id, state->next_id, sizeof(state->this_id));
5eb78dfcd888d3 Sudan Landge 2024-03-25 35 if (!memcmp(old_id, state->this_id, sizeof(old_id)))
5eb78dfcd888d3 Sudan Landge 2024-03-25 36 return;
5eb78dfcd888d3 Sudan Landge 2024-03-25 37 add_vmfork_randomness(state->this_id, sizeof(state->this_id));
fba2c3554a30ca Sudan Landge 2024-03-25 38 kobject_uevent_env(&device->kobj, KOBJ_CHANGE, envp);
5eb78dfcd888d3 Sudan Landge 2024-03-25 39 }
5eb78dfcd888d3 Sudan Landge 2024-03-25 40
84d2b6732ae89f Sudan Landge 2024-03-25 41 #if IS_ENABLED(CONFIG_ACPI)
fba2c3554a30ca Sudan Landge 2024-03-25 42 static void vmgenid_acpi_handler(acpi_handle handle, u32 event, void *dev)
af6b54e2b5baa5 Jason A. Donenfeld 2022-02-23 43 {
84d2b6732ae89f Sudan Landge 2024-03-25 44 (void)handle;
84d2b6732ae89f Sudan Landge 2024-03-25 45 (void)event;
fba2c3554a30ca Sudan Landge 2024-03-25 46 vmgenid_notify(dev);
fba2c3554a30ca Sudan Landge 2024-03-25 47 }
84d2b6732ae89f Sudan Landge 2024-03-25 48 #endif
84d2b6732ae89f Sudan Landge 2024-03-25 49
84d2b6732ae89f Sudan Landge 2024-03-25 50 #if IS_ENABLED(CONFIG_OF)
84d2b6732ae89f Sudan Landge 2024-03-25 51 static irqreturn_t vmgenid_of_irq_handler(int irq, void *dev)
84d2b6732ae89f Sudan Landge 2024-03-25 52 {
84d2b6732ae89f Sudan Landge 2024-03-25 53 (void)irq;
84d2b6732ae89f Sudan Landge 2024-03-25 54 vmgenid_notify(dev);
84d2b6732ae89f Sudan Landge 2024-03-25 55
84d2b6732ae89f Sudan Landge 2024-03-25 56 return IRQ_HANDLED;
84d2b6732ae89f Sudan Landge 2024-03-25 57 }
84d2b6732ae89f Sudan Landge 2024-03-25 58 #endif
fba2c3554a30ca Sudan Landge 2024-03-25 59
fba2c3554a30ca Sudan Landge 2024-03-25 @60 static int setup_vmgenid_state(struct vmgenid_state *state, u8 *next_id)
fba2c3554a30ca Sudan Landge 2024-03-25 61 {
fba2c3554a30ca Sudan Landge 2024-03-25 62 if (IS_ERR(next_id))
fba2c3554a30ca Sudan Landge 2024-03-25 63 return PTR_ERR(next_id);
fba2c3554a30ca Sudan Landge 2024-03-25 64
fba2c3554a30ca Sudan Landge 2024-03-25 65 state->next_id = next_id;
fba2c3554a30ca Sudan Landge 2024-03-25 66 memcpy(state->this_id, state->next_id, sizeof(state->this_id));
fba2c3554a30ca Sudan Landge 2024-03-25 67 add_device_randomness(state->this_id, sizeof(state->this_id));
fba2c3554a30ca Sudan Landge 2024-03-25 68 return 0;
fba2c3554a30ca Sudan Landge 2024-03-25 69 }
fba2c3554a30ca Sudan Landge 2024-03-25 70

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki