Skip to contentSkip to conversation

drivers/virt: vm_gen_counter: initial driver implementation

PATCH Superseded Or Idgar 2 participants 2 messages Feb 25, 2018 Char and misc drivers

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Or Idgar

author
#0 lore raw

PATCH v3 1/1 drivers/virt: vm_gen_counter: initial driver implementation

From: Or Idgar <[email protected]>

This patch is a driver which expose the Virtual Machine Generation ID via sysfs. The ID is a UUID value used to differentiate between virtual machines.

The VM-Generation ID is a feature defined by Microsoft (paper:
http://go.microsoft.com/fwlink/?LinkId=260709) and supported by multiple hypervisor vendors.

---

Changes in v3 from v1 (v2 lack of patch changelog):
- replaced GPL2 section with SPDX line.
- including linux/kobject.h for hypervisor_kobj.
- using acpi_os_map_memory instead acpi_os_map_iomem.

 Documentation/ABI/testing/sysfs-hypervisor |  13 +++
 drivers/misc/Kconfig                       |   6 ++
 drivers/misc/Makefile                      |   1 +
 drivers/misc/vmgenid.c                     | 140 +++++++++++++++++++++++++++++
 4 files changed, 160 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-hypervisor
 create mode 100644 drivers/misc/vmgenid.c
Documentation/ABI/testing/sysfs-hypervisor new file +13 -0
new file mode 100644
index 000000000000..2f9a7b8eab70
@@ -0,0 +1,13 @@
+What:		/sys/hypervisor/vm_gen_counter
+Date:		February 2018
+Contact:	Or Idgar <[email protected]>
+		Gal Hammer <[email protected]>
+Description:	Expose the virtual machine generation ID. The directory
+		contains two files: "generation_id" and "raw". Both files
+		represent the same information.
+
+		"generation_id" file is a UUID string
+		representation.
+
+		"raw" file is a 128-bit integer
+		representation (binary).
drivers/misc/Kconfig +6 -0
index 03605f8fc0dc..5a74802bdfb4 100644
@@ -500,6 +500,12 @@ config MISC_RTSX
 	tristate
 	default MISC_RTSX_PCI || MISC_RTSX_USB
 
+config VMGENID
+	tristate "Virtual Machine Generation ID driver"
+	help
+	  This is a Virtual Machine Generation ID driver which provides
+	  a virtual machine unique identifier.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index c3c8624f4d95..067aa666bb6a 100644
@@ -57,6 +57,7 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)	+= aspeed-lpc-snoop.o
 obj-$(CONFIG_PCI_ENDPOINT_TEST)	+= pci_endpoint_test.o
 obj-$(CONFIG_OCXL)		+= ocxl/
 obj-$(CONFIG_MISC_RTSX)		+= cardreader/
+obj-$(CONFIG_VMGENID)		+= vmgenid.o
 
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_core.o
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_bugs.o
drivers/misc/vmgenid.c new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
2.14.3
#1 lore raw
Quoted 18 lines · Or Idgar

From: Or Idgar <[email protected]>

This patch is a driver which expose the Virtual Machine Generation ID via sysfs. The ID is a UUID value used to differentiate between virtual machines.

The VM-Generation ID is a feature defined by Microsoft (paper:
http://go.microsoft.com/fwlink/?LinkId=260709) and supported by multiple hypervisor vendors.

---

Changes in v3 from v1 (v2 lack of patch changelog):
- replaced GPL2 section with SPDX line.
- including linux/kobject.h for hypervisor_kobj.
- using acpi_os_map_memory instead acpi_os_map_iomem.

Quoted 7 lines
 Documentation/ABI/testing/sysfs-hypervisor |  13 +++
 drivers/misc/Kconfig                       |   6 ++
 drivers/misc/Makefile                      |   1 +
 drivers/misc/vmgenid.c                     | 140 +++++++++++++++++++++++++++++
 4 files changed, 160 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-hypervisor
 create mode 100644 drivers/misc/vmgenid.c

$Subject says drivers/virt/. Please choose one.

Quoted 22 lines
drivers/misc/vmgenid.c new file +16 -0
new file mode 100644
index 000000000000..6b7ec9bd45e8
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Virtual Machine Generation ID driver
+ *
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+ *	Authors:
+ *	  Or Idgar <[email protected]>
+ *	  Gal Hammer <[email protected]>
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/kobject.h>
+#include <linux/acpi.h>
+#include <linux/uuid.h>

drivers/misc/vmgenid.c line 26

Quoted 10 lines
drivers/misc/vmgenid.c new file +10 -0
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Or Idgar <[email protected]>");
+MODULE_AUTHOR("Gal Hammer <[email protected]>");
+MODULE_DESCRIPTION("Virtual Machine Generation ID");
+MODULE_VERSION("0.1");
+
+ACPI_MODULE_NAME("vmgenid");
+
+static u64 phy_addr;

Minor nit:
I would prefer phys_addr since we also have PHY devices that have a phy addr.

thanks,

Signature · 1 line
~Randy