* Re: [PATCH 03/19] drivers/hv: minimal mshv module (/dev/mshv/)
[not found] ` <1622241819-21155-4-git-send-email-nunodasneves@linux.microsoft.com>
@ 2021-05-29 0:01 ` Randy Dunlap
2021-06-03 1:28 ` Sunil Muthuswamy via Virtualization
1 sibling, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2021-05-29 0:01 UTC (permalink / raw)
To: Nuno Das Neves, linux-hyperv, linux-kernel
Cc: wei.liu, ligrassi, mikelley, virtualization, viremana, sunilmut
On 5/28/21 3:43 PM, Nuno Das Neves wrote:
> Introduce a barebones module file for the mshv API.
> Introduce CONFIG_HYPERV_ROOT_API for controlling compilation of mshv.
>
> Co-developed-by: Lillian Grassin-Drake <ligrassi@microsoft.com>
> Signed-off-by: Lillian Grassin-Drake <ligrassi@microsoft.com>
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
Hi,
> diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
> index 66c794d92391..d618b1fab2bb 100644
> --- a/drivers/hv/Kconfig
> +++ b/drivers/hv/Kconfig
> @@ -27,4 +27,22 @@ config HYPERV_BALLOON
> help
> Select this option to enable Hyper-V Balloon driver.
>
> +config HYPERV_ROOT_API
> + tristate "Microsoft Hypervisor root partition interfaces: /dev/mshv"
> + depends on HYPERV
> + help
> + Provides access to interfaces for managing guest virtual machines
> + running under the Microsoft Hypervisor.
> +
> + These interfaces will only work when Linux is running as root
> + partition on the Microsoft Hypervisor.
> +
> + The interfaces are provided via a device named /dev/mshv.
> +
> + To compile this as a module, choose M here.
> + The module is named mshv.
^^^^^^^^^^^^^
Please follow coding-style for Kconfig files:
(from Documentation/process/coding-style.rst, section 10):
For all of the Kconfig* configuration files throughout the source tree,
the indentation is somewhat different. Lines under a ``config`` definition
are indented with one tab, while help text is indented an additional two
spaces.
> +
> + If unsure, say N.
> +
> +
> endmenu
thanks.
--
~Randy
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 03/19] drivers/hv: minimal mshv module (/dev/mshv/)
[not found] ` <1622241819-21155-4-git-send-email-nunodasneves@linux.microsoft.com>
2021-05-29 0:01 ` [PATCH 03/19] drivers/hv: minimal mshv module (/dev/mshv/) Randy Dunlap
@ 2021-06-03 1:28 ` Sunil Muthuswamy via Virtualization
1 sibling, 0 replies; 5+ messages in thread
From: Sunil Muthuswamy via Virtualization @ 2021-06-03 1:28 UTC (permalink / raw)
To: Nuno Das Neves, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: wei.liu@kernel.org, Lillian Grassin-Drake, Michael Kelley,
virtualization@lists.linux-foundation.org,
viremana@linux.microsoft.com
> diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
> index 66c794d92391..d618b1fab2bb 100644
> --- a/drivers/hv/Kconfig
> +++ b/drivers/hv/Kconfig
> @@ -27,4 +27,22 @@ config HYPERV_BALLOON
> help
> Select this option to enable Hyper-V Balloon driver.
>
> +config HYPERV_ROOT_API
A more suitable place to put this would be under the "VIRTUALIZATION"
config menu option, where we have the "KVM" option today.
> + tristate "Microsoft Hypervisor root partition interfaces: /dev/mshv"
> + depends on HYPERV
> + help
> + Provides access to interfaces for managing guest virtual machines
> + running under the Microsoft Hypervisor.
These are technically not "root" interfaces. As you say it too, these are
interfaces to manage guest VMs. Calling it "HYPERV_ROOT_API" would
be confusing. Something along the lines of "HYPERV_VMM_API" or
"HYPERV_VM_API" seems more appropriate to me.
> new file mode 100644
> index 000000000000..c68cc84fb983
> --- /dev/null
> +++ b/drivers/hv/mshv_main.c
Why not in /virt/hv or something under /virt?
> +static int mshv_dev_open(struct inode *inode, struct file *filp);
> +static int mshv_dev_release(struct inode *inode, struct file *filp);
> +static long mshv_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg);
Do we need to have both 'mshv' & 'dev' in the name? How about just
calling these 'mshv_xyz'? Like you have for init/exit.
> +
> +static struct miscdevice mshv_dev = {
> + .minor = MISC_DYNAMIC_MINOR,
> + .name = "mshv",
> + .fops = &mshv_dev_fops,
> + .mode = 600,
> +};
For the default mode, I think we want to keep it the same as that for 'kvm'.
- Sunil
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 00/19] Microsoft Hypervisor root partition ioctl interface
[not found] <1622241819-21155-1-git-send-email-nunodasneves@linux.microsoft.com>
[not found] ` <1622241819-21155-4-git-send-email-nunodasneves@linux.microsoft.com>
@ 2021-06-10 9:22 ` Vitaly Kuznetsov
[not found] ` <1622241819-21155-2-git-send-email-nunodasneves@linux.microsoft.com>
[not found] ` <1622241819-21155-3-git-send-email-nunodasneves@linux.microsoft.com>
3 siblings, 0 replies; 5+ messages in thread
From: Vitaly Kuznetsov @ 2021-06-10 9:22 UTC (permalink / raw)
To: Nuno Das Neves
Cc: wei.liu, linux-hyperv, linux-kernel, mikelley, sunilmut,
virtualization, viremana, ligrassi
Nuno Das Neves <nunodasneves@linux.microsoft.com> writes:
> This patch series provides a userspace interface for creating and running guest
> virtual machines while running on the Microsoft Hypervisor [0].
>
> Since managing guest machines can only be done when Linux is the root partition,
> this series depends on Wei Liu's patch series merged in 5.12:
> https://lore.kernel.org/linux-hyperv/20210203150435.27941-1-wei.liu@kernel.org/
>
> The first two patches provide some helpers for converting hypervisor status
> codes to linux error codes, and printing hypervisor status codes to dmesg for
> debugging.
>
> Hyper-V related headers asm-generic/hyperv-tlfs.h and x86/asm/hyperv-tlfs.h are
> split into uapi and non-uapi. The uapi versions contain structures used in both
> the ioctl interface and the kernel.
>
> The mshv API is introduced in drivers/hv/mshv_main.c. As each interface is
> introduced, documentation is added in Documentation/virt/mshv/api.rst.
> The API is file-desciptor based, like KVM. The entry point is /dev/mshv.
>
> /dev/mshv ioctls:
> MSHV_CHECK_EXTENSION
> MSHV_CREATE_PARTITION
>
> Partition (vm) ioctls:
> MSHV_MAP_GUEST_MEMORY, MSHV_UNMAP_GUEST_MEMORY
> MSHV_INSTALL_INTERCEPT
> MSHV_ASSERT_INTERRUPT
> MSHV_GET_PARTITION_PROPERTY, MSHV_SET_PARTITION_PROPERTY
> MSHV_CREATE_VP
>
> Vp (vcpu) ioctls:
> MSHV_GET_VP_REGISTERS, MSHV_SET_VP_REGISTERS
> MSHV_RUN_VP
> MSHV_GET_VP_STATE, MSHV_SET_VP_STATE
> MSHV_TRANSLATE_GVA
> mmap() (register page)
>
> [0] Hyper-V is more well-known, but it really refers to the whole stack
> including the hypervisor and other components that run in Windows kernel
> and userspace.
>
> Changes since RFC:
> 1. Moved code from virt/mshv to drivers/hv
> 2. Split hypercall helper functions and synic code to hv_call.c and hv_synic.c
> 3. MSHV_REQUEST_VERSION ioctl replaced with MSHV_CHECK_EXTENSION
> 3. Numerous suggestions, fixes, style changes, etc from Michael Kelley, Vitaly
> Kuznetsov, Wei Liu, and Vineeth Pillai
> 4. Added patch to enable hypervisor enlightenments on partition creation
> 5. Added Wei Liu's patch for GVA to GPA translation
>
Thank you for addressing these!
One nitpick though: could you please run your next submission through
'scripts/checkpatch.pl'? It reports a number of issues here, mostly
minor but still worth addressing, i.e.:
$ scripts/checkpatch.pl *.patch
...
---------------------------------------------------------------
0002-asm-generic-hyperv-convert-hyperv-statuses-to-string.patch
---------------------------------------------------------------
ERROR: Macros with complex values should be enclosed in parentheses
#95: FILE: include/asm-generic/hyperv-tlfs.h:192:
+#define __HV_STATUS_DEF(OP) \
+ OP(HV_STATUS_SUCCESS, 0x0) \
...
ERROR: Macros with complex values should be enclosed in parentheses
#119: FILE: include/asm-generic/hyperv-tlfs.h:216:
+#define __HV_MAKE_HV_STATUS_ENUM(NAME, VAL) NAME = (VAL),
ERROR: Macros with multiple statements should be enclosed in a do - while loop
#120: FILE: include/asm-generic/hyperv-tlfs.h:217:
+#define __HV_MAKE_HV_STATUS_CASE(NAME, VAL) case (NAME): return (#NAME);
WARNING: Macros with flow control statements should be avoided
#120: FILE: include/asm-generic/hyperv-tlfs.h:217:
+#define __HV_MAKE_HV_STATUS_CASE(NAME, VAL) case (NAME): return (#NAME);
WARNING: macros should not use a trailing semicolon
#120: FILE: include/asm-generic/hyperv-tlfs.h:217:
+#define __HV_MAKE_HV_STATUS_CASE(NAME, VAL) case (NAME): return (#NAME);
total: 3 errors, 2 warnings, 108 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
0002-asm-generic-hyperv-convert-hyperv-statuses-to-string.patch has
style problems, please review.
...
-------------------------------------------
0004-drivers-hv-check-extension-ioctl.patch
-------------------------------------------
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#36:
new file mode 100644
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
#131: FILE: drivers/hv/mshv_main.c:52:
+ return -ENOTSUPP;
total: 0 errors, 2 warnings, 137 lines checked
...
WARNING: Improper SPDX comment style for 'drivers/hv/hv_call.c', please use '//' instead
#94: FILE: drivers/hv/hv_call.c:1:
+/* SPDX-License-Identifier: GPL-2.0-only */
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#94: FILE: drivers/hv/hv_call.c:1:
+/* SPDX-License-Identifier: GPL-2.0-only */
ERROR: "(foo*)" should be "(foo *)"
#178: FILE: drivers/hv/hv_call.c:85:
+ *(u64*)&input);
ERROR: "(foo*)" should be "(foo *)"
#201: FILE: drivers/hv/hv_call.c:108:
+ *(u64*)&input);
ERROR: "(foo*)" should be "(foo *)"
#215: FILE: drivers/hv/hv_call.c:122:
+ status = hv_do_fast_hypercall8(HVCALL_DELETE_PARTITION, *(u64*)&input);
total: 3 errors, 3 warnings, 330 lines checked
...
------------------------------------------------
0008-drivers-hv-map-and-unmap-guest-memory.patch
------------------------------------------------
ERROR: code indent should use tabs where possible
#101: FILE: drivers/hv/hv_call.c:222:
+ HV_MAP_GPA_DEPOSIT_PAGES);$
WARNING: please, no spaces at the start of a line
#101: FILE: drivers/hv/hv_call.c:222:
+ HV_MAP_GPA_DEPOSIT_PAGES);$
ERROR: code indent should use tabs where possible
#469: FILE: include/asm-generic/hyperv-tlfs.h:895:
+ u32 padding;$
WARNING: please, no spaces at the start of a line
#469: FILE: include/asm-generic/hyperv-tlfs.h:895:
+ u32 padding;$
ERROR: code indent should use tabs where possible
#477: FILE: include/asm-generic/hyperv-tlfs.h:903:
+ u32 padding;$
WARNING: please, no spaces at the start of a line
#477: FILE: include/asm-generic/hyperv-tlfs.h:903:
+ u32 padding;$
total: 3 errors, 3 warnings, 487 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
NOTE: Whitespace errors detected.
You may wish to use scripts/cleanpatch or scripts/cleanfile
0008-drivers-hv-map-and-unmap-guest-memory.patch has style problems, please review.
---------------------------------------
0009-drivers-hv-create-vcpu-ioctl.patch
---------------------------------------
WARNING: Missing a blank line after declarations
#76: FILE: drivers/hv/mshv_main.c:75:
+ struct mshv_vp *vp = filp->private_data;
+ mshv_partition_put(vp->partition);
ERROR: trailing whitespace
#180: FILE: drivers/hv/mshv_main.c:376:
+^I$
total: 1 errors, 1 warnings, 210 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
NOTE: Whitespace errors detected.
You may wish to use scripts/cleanpatch or scripts/cleanfile
0009-drivers-hv-create-vcpu-ioctl.patch has style problems, please review.
-------------------------------------------------------
0010-drivers-hv-get-and-set-vcpu-registers-ioctls.patch
-------------------------------------------------------
WARNING: braces {} are not necessary for single statement blocks
#690: FILE: drivers/hv/hv_call.c:326:
+ for (i = 0; i < rep_count; ++i) {
+ input_page->names[i] = registers[i].name;
+ }
WARNING: braces {} are not necessary for single statement blocks
#704: FILE: drivers/hv/hv_call.c:340:
+ for (i = 0; i < completed; ++i) {
+ registers[i].value = output_page[i];
+ }
WARNING: braces {} are not necessary for single statement blocks
#859: FILE: drivers/hv/mshv_main.c:121:
+ if (!registers) {
+ return -ENOMEM;
+ }
total: 0 errors, 3 warnings, 965 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
0010-drivers-hv-get-and-set-vcpu-registers-ioctls.patch has style problems, please review.
---------------------------------------------------------------
0011-drivers-hv-set-up-synic-pages-for-intercept-messages.patch
---------------------------------------------------------------
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#274:
new file mode 100644
ERROR: code indent should use tabs where possible
#310: FILE: drivers/hv/hv_synic.c:32:
+ MEMREMAP_WB);$
WARNING: please, no spaces at the start of a line
#310: FILE: drivers/hv/hv_synic.c:32:
+ MEMREMAP_WB);$
total: 1 errors, 2 warnings, 574 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
NOTE: Whitespace errors detected.
You may wish to use scripts/cleanpatch or scripts/cleanfile
0011-drivers-hv-set-up-synic-pages-for-intercept-messages.patch has style problems, please review.
------------------------------------------
0012-drivers-hv-run-vp-ioctl-and-isr.patch
------------------------------------------
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
#86: FILE: arch/x86/kernel/cpu/mshyperv.c:77:
+EXPORT_SYMBOL_GPL(hv_remove_mshv_irq);
WARNING: consider using a completion
#410: FILE: drivers/hv/mshv_main.c:344:
+ sema_init(&vp->run.sem, 0);
total: 0 errors, 2 warnings, 435 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
0012-drivers-hv-run-vp-ioctl-and-isr.patch has style problems, please review.
---------------------------------------------
...
-------------------------------------------
0016-drivers-hv-mmap-vp-register-page.patch
-------------------------------------------
WARNING: Missing a blank line after declarations
#222: FILE: drivers/hv/mshv_main.c:441:
+ struct mshv_vp *vp = vmf->vma->vm_file->private_data;
+ vmf->page = vp->register_page;
total: 0 errors, 1 warnings, 257 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
0016-drivers-hv-mmap-vp-register-page.patch has style problems, please review.
-----------------------------------------------------------
0017-drivers-hv-get-and-set-partition-property-ioctls.patch
-----------------------------------------------------------
ERROR: code indent should use tabs where possible
#205: FILE: include/asm-generic/hyperv-tlfs.h:890:
+ u32 padding;$
WARNING: please, no spaces at the start of a line
#205: FILE: include/asm-generic/hyperv-tlfs.h:890:
+ u32 padding;$
ERROR: code indent should use tabs where possible
#215: FILE: include/asm-generic/hyperv-tlfs.h:900:
+ u32 padding;$
WARNING: please, no spaces at the start of a line
#215: FILE: include/asm-generic/hyperv-tlfs.h:900:
+ u32 padding;$
total: 2 errors, 2 warnings, 258 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
NOTE: Whitespace errors detected.
You may wish to use scripts/cleanpatch or scripts/cleanfile
--
Vitaly
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 01/19] x86/hyperv: convert hyperv statuses to linux error codes
[not found] ` <1622241819-21155-2-git-send-email-nunodasneves@linux.microsoft.com>
@ 2021-06-10 18:22 ` Sunil Muthuswamy via Virtualization
0 siblings, 0 replies; 5+ messages in thread
From: Sunil Muthuswamy via Virtualization @ 2021-06-10 18:22 UTC (permalink / raw)
To: Nuno Das Neves, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: wei.liu@kernel.org, Lillian Grassin-Drake, Michael Kelley,
virtualization@lists.linux-foundation.org,
viremana@linux.microsoft.com
> -----Original Message-----
> From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> Sent: Friday, May 28, 2021 3:43 PM
> To: linux-hyperv@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: virtualization@lists.linux-foundation.org; Michael Kelley <mikelley@microsoft.com>; viremana@linux.microsoft.com; Sunil
> Muthuswamy <sunilmut@microsoft.com>; wei.liu@kernel.org; vkuznets <vkuznets@redhat.com>; Lillian Grassin-Drake
> <Lillian.GrassinDrake@microsoft.com>; KY Srinivasan <kys@microsoft.com>
> Subject: [PATCH 01/19] x86/hyperv: convert hyperv statuses to linux error codes
>
> Return linux-friendly error codes from hypercall wrapper functions.
> This will be needed in the mshv module.
>
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
> arch/x86/hyperv/hv_proc.c | 30 ++++++++++++++++++++++++++---
> arch/x86/include/asm/mshyperv.h | 1 +
> include/asm-generic/hyperv-tlfs.h | 32 +++++++++++++++++++++----------
> 3 files changed, 50 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_proc.c b/arch/x86/hyperv/hv_proc.c
> index 68a0843d4750..59cf9a9e0975 100644
> --- a/arch/x86/hyperv/hv_proc.c
> +++ b/arch/x86/hyperv/hv_proc.c
> @@ -14,6 +14,30 @@
>
> #include <asm/trace/hyperv.h>
>
> +int hv_status_to_errno(u64 hv_status)
> +{
> + switch (hv_result(hv_status)) {
> + case HV_STATUS_SUCCESS:
> + return 0;
> + case HV_STATUS_INVALID_PARAMETER:
> + case HV_STATUS_UNKNOWN_PROPERTY:
> + case HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE:
> + case HV_STATUS_INVALID_VP_INDEX:
> + case HV_STATUS_INVALID_REGISTER_VALUE:
> + case HV_STATUS_INVALID_LP_INDEX:
> + return -EINVAL;
> + case HV_STATUS_ACCESS_DENIED:
> + case HV_STATUS_OPERATION_DENIED:
> + return -EACCES;
> + case HV_STATUS_NOT_ACKNOWLEDGED:
> + case HV_STATUS_INVALID_VP_STATE:
> + case HV_STATUS_INVALID_PARTITION_STATE:
> + return -EBADFD;
> + }
> + return -ENOTRECOVERABLE;
> +}
> +EXPORT_SYMBOL_GPL(hv_status_to_errno);
> +
> /*
> * See struct hv_deposit_memory. The first u64 is partition ID, the rest
> * are GPAs.
> @@ -94,7 +118,7 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
> local_irq_restore(flags);
> if (!hv_result_success(status)) {
> pr_err("Failed to deposit pages: %lld\n", status);
> - ret = hv_result(status);
> + ret = hv_status_to_errno(status);
> goto err_free_allocations;
> }
>
> @@ -150,7 +174,7 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u32 apic_id)
> if (!hv_result_success(status)) {
> pr_err("%s: cpu %u apic ID %u, %lld\n", __func__,
> lp_index, apic_id, status);
> - ret = hv_result(status);
> + ret = hv_status_to_errno(status);
> }
> break;
> }
> @@ -200,7 +224,7 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags)
> if (!hv_result_success(status)) {
> pr_err("%s: vcpu %u, lp %u, %lld\n", __func__,
> vp_index, flags, status);
> - ret = hv_result(status);
> + ret = hv_status_to_errno(status);
> }
> break;
> }
> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> index 67ff0d637e55..c6eb01f3864d 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -169,6 +169,7 @@ int hyperv_flush_guest_mapping_range(u64 as,
> int hyperv_fill_flush_guest_mapping_list(
> struct hv_guest_mapping_flush_list *flush,
> u64 start_gfn, u64 end_gfn);
> +int hv_status_to_errno(u64 hv_status);
>
> extern bool hv_root_partition;
>
> diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h
> index 515c3fb06ab3..fe6d41d0b114 100644
> --- a/include/asm-generic/hyperv-tlfs.h
> +++ b/include/asm-generic/hyperv-tlfs.h
> @@ -189,16 +189,28 @@ enum HV_GENERIC_SET_FORMAT {
> #define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48)
>
> /* hypercall status code */
> -#define HV_STATUS_SUCCESS 0
> -#define HV_STATUS_INVALID_HYPERCALL_CODE 2
> -#define HV_STATUS_INVALID_HYPERCALL_INPUT 3
> -#define HV_STATUS_INVALID_ALIGNMENT 4
> -#define HV_STATUS_INVALID_PARAMETER 5
> -#define HV_STATUS_OPERATION_DENIED 8
> -#define HV_STATUS_INSUFFICIENT_MEMORY 11
> -#define HV_STATUS_INVALID_PORT_ID 17
> -#define HV_STATUS_INVALID_CONNECTION_ID 18
> -#define HV_STATUS_INSUFFICIENT_BUFFERS 19
> +#define HV_STATUS_SUCCESS 0x0
> +#define HV_STATUS_INVALID_HYPERCALL_CODE 0x2
> +#define HV_STATUS_INVALID_HYPERCALL_INPUT 0x3
> +#define HV_STATUS_INVALID_ALIGNMENT 0x4
> +#define HV_STATUS_INVALID_PARAMETER 0x5
> +#define HV_STATUS_ACCESS_DENIED 0x6
> +#define HV_STATUS_INVALID_PARTITION_STATE 0x7
> +#define HV_STATUS_OPERATION_DENIED 0x8
> +#define HV_STATUS_UNKNOWN_PROPERTY 0x9
> +#define HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE 0xA
> +#define HV_STATUS_INSUFFICIENT_MEMORY 0xB
> +#define HV_STATUS_INVALID_PARTITION_ID 0xD
> +#define HV_STATUS_INVALID_VP_INDEX 0xE
> +#define HV_STATUS_NOT_FOUND 0x10
> +#define HV_STATUS_INVALID_PORT_ID 0x11
> +#define HV_STATUS_INVALID_CONNECTION_ID 0x12
> +#define HV_STATUS_INSUFFICIENT_BUFFERS 0x13
> +#define HV_STATUS_NOT_ACKNOWLEDGED 0x14
> +#define HV_STATUS_INVALID_VP_STATE 0x15
> +#define HV_STATUS_NO_RESOURCES 0x1D
> +#define HV_STATUS_INVALID_LP_INDEX 0x41
> +#define HV_STATUS_INVALID_REGISTER_VALUE 0x50
>
> /*
> * The Hyper-V TimeRefCount register and the TSC
> --
> 2.25.1
Reviewed-by: Sunil Muthuswamy <sunilmut@microsoft.com>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 02/19] asm-generic/hyperv: convert hyperv statuses to strings
[not found] ` <1622241819-21155-3-git-send-email-nunodasneves@linux.microsoft.com>
@ 2021-06-10 18:42 ` Sunil Muthuswamy via Virtualization
0 siblings, 0 replies; 5+ messages in thread
From: Sunil Muthuswamy via Virtualization @ 2021-06-10 18:42 UTC (permalink / raw)
To: Nuno Das Neves, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: wei.liu@kernel.org, Lillian Grassin-Drake, Michael Kelley,
virtualization@lists.linux-foundation.org,
viremana@linux.microsoft.com
> -----Original Message-----
> From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> Sent: Friday, May 28, 2021 3:43 PM
> To: linux-hyperv@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: virtualization@lists.linux-foundation.org; Michael Kelley <mikelley@microsoft.com>; viremana@linux.microsoft.com; Sunil
> Muthuswamy <sunilmut@microsoft.com>; wei.liu@kernel.org; vkuznets <vkuznets@redhat.com>; Lillian Grassin-Drake
> <Lillian.GrassinDrake@microsoft.com>; KY Srinivasan <kys@microsoft.com>
> Subject: [PATCH 02/19] asm-generic/hyperv: convert hyperv statuses to strings
>
> Allow hyperv hypercall failures to be debugged more easily with dmesg.
> This will be used in the mshv module.
>
> Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
> ---
> arch/x86/hyperv/hv_init.c | 2 +-
> arch/x86/hyperv/hv_proc.c | 10 +++---
> include/asm-generic/hyperv-tlfs.h | 52 ++++++++++++++++++-------------
> include/asm-generic/mshyperv.h | 8 +++++
> 4 files changed, 44 insertions(+), 28 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index bb0ae4b5c00f..722bafdb2225 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -349,7 +349,7 @@ static void __init hv_get_partition_id(void)
> status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output_page);
> if (!hv_result_success(status)) {
> /* No point in proceeding if this failed */
> - pr_err("Failed to get partition ID: %lld\n", status);
> + pr_err("Failed to get partition ID: %s\n", hv_status_to_string(status));
> BUG();
> }
> hv_current_partition_id = output_page->partition_id;
> diff --git a/arch/x86/hyperv/hv_proc.c b/arch/x86/hyperv/hv_proc.c
> index 59cf9a9e0975..30951e778577 100644
> --- a/arch/x86/hyperv/hv_proc.c
> +++ b/arch/x86/hyperv/hv_proc.c
> @@ -117,7 +117,7 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
> page_count, 0, input_page, NULL);
> local_irq_restore(flags);
> if (!hv_result_success(status)) {
> - pr_err("Failed to deposit pages: %lld\n", status);
> + pr_err("Failed to deposit pages: %s\n", hv_status_to_string(status));
> ret = hv_status_to_errno(status);
> goto err_free_allocations;
> }
> @@ -172,8 +172,8 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u32 apic_id)
>
> if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> if (!hv_result_success(status)) {
> - pr_err("%s: cpu %u apic ID %u, %lld\n", __func__,
> - lp_index, apic_id, status);
> + pr_err("%s: cpu %u apic ID %u, %s\n", __func__,
> + lp_index, apic_id, hv_status_to_string(status));
> ret = hv_status_to_errno(status);
> }
> break;
> @@ -222,8 +222,8 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags)
>
> if (hv_result(status) != HV_STATUS_INSUFFICIENT_MEMORY) {
> if (!hv_result_success(status)) {
> - pr_err("%s: vcpu %u, lp %u, %lld\n", __func__,
> - vp_index, flags, status);
> + pr_err("%s: vcpu %u, lp %u, %s\n", __func__,
> + vp_index, flags, hv_status_to_string(status));
> ret = hv_status_to_errno(status);
> }
> break;
> diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h
> index fe6d41d0b114..40ff7cdd4a2b 100644
> --- a/include/asm-generic/hyperv-tlfs.h
> +++ b/include/asm-generic/hyperv-tlfs.h
> @@ -189,28 +189,36 @@ enum HV_GENERIC_SET_FORMAT {
> #define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48)
>
> /* hypercall status code */
> -#define HV_STATUS_SUCCESS 0x0
> -#define HV_STATUS_INVALID_HYPERCALL_CODE 0x2
> -#define HV_STATUS_INVALID_HYPERCALL_INPUT 0x3
> -#define HV_STATUS_INVALID_ALIGNMENT 0x4
> -#define HV_STATUS_INVALID_PARAMETER 0x5
> -#define HV_STATUS_ACCESS_DENIED 0x6
> -#define HV_STATUS_INVALID_PARTITION_STATE 0x7
> -#define HV_STATUS_OPERATION_DENIED 0x8
> -#define HV_STATUS_UNKNOWN_PROPERTY 0x9
> -#define HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE 0xA
> -#define HV_STATUS_INSUFFICIENT_MEMORY 0xB
> -#define HV_STATUS_INVALID_PARTITION_ID 0xD
> -#define HV_STATUS_INVALID_VP_INDEX 0xE
> -#define HV_STATUS_NOT_FOUND 0x10
> -#define HV_STATUS_INVALID_PORT_ID 0x11
> -#define HV_STATUS_INVALID_CONNECTION_ID 0x12
> -#define HV_STATUS_INSUFFICIENT_BUFFERS 0x13
> -#define HV_STATUS_NOT_ACKNOWLEDGED 0x14
> -#define HV_STATUS_INVALID_VP_STATE 0x15
> -#define HV_STATUS_NO_RESOURCES 0x1D
> -#define HV_STATUS_INVALID_LP_INDEX 0x41
> -#define HV_STATUS_INVALID_REGISTER_VALUE 0x50
> +#define __HV_STATUS_DEF(OP) \
> + OP(HV_STATUS_SUCCESS, 0x0) \
> + OP(HV_STATUS_INVALID_HYPERCALL_CODE, 0x2) \
> + OP(HV_STATUS_INVALID_HYPERCALL_INPUT, 0x3) \
> + OP(HV_STATUS_INVALID_ALIGNMENT, 0x4) \
> + OP(HV_STATUS_INVALID_PARAMETER, 0x5) \
> + OP(HV_STATUS_ACCESS_DENIED, 0x6) \
> + OP(HV_STATUS_INVALID_PARTITION_STATE, 0x7) \
> + OP(HV_STATUS_OPERATION_DENIED, 0x8) \
> + OP(HV_STATUS_UNKNOWN_PROPERTY, 0x9) \
> + OP(HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE, 0xA) \
> + OP(HV_STATUS_INSUFFICIENT_MEMORY, 0xB) \
> + OP(HV_STATUS_INVALID_PARTITION_ID, 0xD) \
> + OP(HV_STATUS_INVALID_VP_INDEX, 0xE) \
> + OP(HV_STATUS_NOT_FOUND, 0x10) \
> + OP(HV_STATUS_INVALID_PORT_ID, 0x11) \
> + OP(HV_STATUS_INVALID_CONNECTION_ID, 0x12) \
> + OP(HV_STATUS_INSUFFICIENT_BUFFERS, 0x13) \
> + OP(HV_STATUS_NOT_ACKNOWLEDGED, 0x14) \
> + OP(HV_STATUS_INVALID_VP_STATE, 0x15) \
> + OP(HV_STATUS_NO_RESOURCES, 0x1D) \
> + OP(HV_STATUS_INVALID_LP_INDEX, 0x41) \
> + OP(HV_STATUS_INVALID_REGISTER_VALUE, 0x50)
> +
> +#define __HV_MAKE_HV_STATUS_ENUM(NAME, VAL) NAME = (VAL),
> +#define __HV_MAKE_HV_STATUS_CASE(NAME, VAL) case (NAME): return (#NAME);
> +
> +enum hv_status {
> + __HV_STATUS_DEF(__HV_MAKE_HV_STATUS_ENUM)
> +};
>
> /*
> * The Hyper-V TimeRefCount register and the TSC
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index 9a000ba2bb75..21fb71ca1ba9 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -59,6 +59,14 @@ static inline unsigned int hv_repcomp(u64 status)
> HV_HYPERCALL_REP_COMP_OFFSET;
> }
>
> +static inline const char *hv_status_to_string(u64 hv_status)
> +{
> + switch (hv_result(hv_status)) {
> + __HV_STATUS_DEF(__HV_MAKE_HV_STATUS_CASE)
> + default : return "Unknown";
> + }
> +}
Wouldn't this be a big switch statement that will get duplicated all over the place
in the code because of the inline (and also the strings within)?
- Sunil
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-06-10 18:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1622241819-21155-1-git-send-email-nunodasneves@linux.microsoft.com>
[not found] ` <1622241819-21155-4-git-send-email-nunodasneves@linux.microsoft.com>
2021-05-29 0:01 ` [PATCH 03/19] drivers/hv: minimal mshv module (/dev/mshv/) Randy Dunlap
2021-06-03 1:28 ` Sunil Muthuswamy via Virtualization
2021-06-10 9:22 ` [PATCH 00/19] Microsoft Hypervisor root partition ioctl interface Vitaly Kuznetsov
[not found] ` <1622241819-21155-2-git-send-email-nunodasneves@linux.microsoft.com>
2021-06-10 18:22 ` [PATCH 01/19] x86/hyperv: convert hyperv statuses to linux error codes Sunil Muthuswamy via Virtualization
[not found] ` <1622241819-21155-3-git-send-email-nunodasneves@linux.microsoft.com>
2021-06-10 18:42 ` [PATCH 02/19] asm-generic/hyperv: convert hyperv statuses to strings Sunil Muthuswamy via Virtualization
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).