Re: [Xen-devel] [PATCH v2 03/11] hvmctl: convert HVMOP_set_isa_irq_level

2016-07-05 Thread Daniel De Graaf

On 06/24/2016 06:29 AM, Jan Beulich wrote:

Note that this retains the hvmop interface definitions as those had
(wrongly) been exposed to non-tool stack consumers (albeit the
operation wouldn't have succeeded when requested by a domain for
itself).

Signed-off-by: Jan Beulich 
Reviewed-by: Wei Liu 
Reviewed-by: Andrew Cooper 


Acked-by: Daniel De Graaf 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 03/11] hvmctl: convert HVMOP_set_isa_irq_level

2016-06-24 Thread Jan Beulich
Note that this retains the hvmop interface definitions as those had
(wrongly) been exposed to non-tool stack consumers (albeit the
operation wouldn't have succeeded when requested by a domain for
itself).

Signed-off-by: Jan Beulich 
Reviewed-by: Wei Liu 
Reviewed-by: Andrew Cooper 

--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -488,27 +488,11 @@ int xc_hvm_set_isa_irq_level(
 uint8_t isa_irq,
 unsigned int level)
 {
-DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_isa_irq_level, arg);
-int rc;
+DECLARE_HVMCTL(set_isa_irq_level, dom,
+   .isa_irq = isa_irq,
+   .level   = level);
 
-arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
-if ( arg == NULL )
-{
-PERROR("Could not allocate memory for xc_hvm_set_isa_irq_level 
hypercall");
-return -1;
-}
-
-arg->domid   = dom;
-arg->isa_irq = isa_irq;
-arg->level   = level;
-
-rc = xencall2(xch->xcall, __HYPERVISOR_hvm_op,
-  HVMOP_set_isa_irq_level,
-  HYPERCALL_BUFFER_AS_ARG(arg));
-
-xc_hypercall_buffer_free(xch, arg);
-
-return rc;
+return do_hvmctl(xch, );
 }
 
 int xc_hvm_set_pci_link_route(
--- a/xen/arch/x86/hvm/control.c
+++ b/xen/arch/x86/hvm/control.c
@@ -43,6 +43,30 @@ static int set_pci_intx_level(struct dom
 return 0;
 }
 
+static int set_isa_irq_level(struct domain *d,
+ const struct xen_hvm_set_isa_irq_level *op)
+{
+if ( op->isa_irq > 15 )
+return -EINVAL;
+
+if ( !is_hvm_domain(d) )
+return -EINVAL;
+
+switch ( op->level )
+{
+case 0:
+hvm_isa_irq_deassert(d, op->isa_irq);
+break;
+case 1:
+hvm_isa_irq_assert(d, op->isa_irq);
+break;
+default:
+return -EINVAL;
+}
+
+return 0;
+}
+
 long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl)
 {
 xen_hvmctl_t op;
@@ -80,6 +104,10 @@ long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xe
 rc = set_pci_intx_level(d, _pci_intx_level);
 break;
 
+case XEN_HVMCTL_set_isa_irq_level:
+rc = set_isa_irq_level(d, _isa_irq_level);
+break;
+
 default:
 rc = -EOPNOTSUPP;
 break;
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4446,50 +4446,6 @@ static void hvm_s3_resume(struct domain
 }
 }
 
-static int hvmop_set_isa_irq_level(
-XEN_GUEST_HANDLE_PARAM(xen_hvm_set_isa_irq_level_t) uop)
-{
-struct xen_hvm_set_isa_irq_level op;
-struct domain *d;
-int rc;
-
-if ( copy_from_guest(, uop, 1) )
-return -EFAULT;
-
-if ( op.isa_irq > 15 )
-return -EINVAL;
-
-rc = rcu_lock_remote_domain_by_id(op.domid, );
-if ( rc != 0 )
-return rc;
-
-rc = -EINVAL;
-if ( !is_hvm_domain(d) )
-goto out;
-
-rc = xsm_hvm_set_isa_irq_level(XSM_DM_PRIV, d);
-if ( rc )
-goto out;
-
-rc = 0;
-switch ( op.level )
-{
-case 0:
-hvm_isa_irq_deassert(d, op.isa_irq);
-break;
-case 1:
-hvm_isa_irq_assert(d, op.isa_irq);
-break;
-default:
-rc = -EINVAL;
-break;
-}
-
- out:
-rcu_unlock_domain(d);
-return rc;
-}
-
 static int hvmop_set_pci_link_route(
 XEN_GUEST_HANDLE_PARAM(xen_hvm_set_pci_link_route_t) uop)
 {
@@ -5364,11 +5320,6 @@ long do_hvm_op(unsigned long op, XEN_GUE
 guest_handle_cast(arg, xen_hvm_param_t));
 break;
 
-case HVMOP_set_isa_irq_level:
-rc = hvmop_set_isa_irq_level(
-guest_handle_cast(arg, xen_hvm_set_isa_irq_level_t));
-break;
-
 case HVMOP_inject_msi:
 rc = hvmop_inject_msi(
 guest_handle_cast(arg, xen_hvm_inject_msi_t));
--- a/xen/include/public/hvm/control.h
+++ b/xen/include/public/hvm/control.h
@@ -38,14 +38,25 @@ struct xen_hvm_set_pci_intx_level {
 uint8_t level;
 };
 
+/* XEN_HVMCTL_set_isa_irq_level */
+/* Set the logical level of one of a domain's ISA IRQ wires. */
+struct xen_hvm_set_isa_irq_level {
+/* ISA device identification, by ISA IRQ (0-15). */
+uint8_t  isa_irq;
+/* Assertion level (0 = unasserted, 1 = asserted). */
+uint8_t  level;
+};
+
 struct xen_hvmctl {
 uint16_t interface_version;/* XEN_HVMCTL_INTERFACE_VERSION */
 domid_t domain;
 uint32_t cmd;
 #define XEN_HVMCTL_set_pci_intx_level1
+#define XEN_HVMCTL_set_isa_irq_level 2
 uint64_t opaque;   /* Must be zero on initial invocation. */
 union {
 struct xen_hvm_set_pci_intx_level set_pci_intx_level;
+struct xen_hvm_set_isa_irq_level set_isa_irq_level;
 uint8_t pad[120];
 } u;
 };
--- a/xen/include/public/hvm/hvm_op.h
+++ b/xen/include/public/hvm/hvm_op.h
@@ -53,8 +53,6 @@ struct xen_hvm_set_pci_intx_level {
 typedef struct xen_hvm_set_pci_intx_level xen_hvm_set_pci_intx_level_t;