Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-6.0-rc1b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull more xen updates from Juergen Gross:

- fix the handling of the "persistent grants" feature negotiation
between Xen blkfront and Xen blkback drivers

- a cleanup of xen.config and adding xen.config to Xen section in
MAINTAINERS

- support HVMOP_set_evtchn_upcall_vector, which is more compliant to
"normal" interrupt handling than the global callback used up to now

- further small cleanups

* tag 'for-linus-6.0-rc1b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
MAINTAINERS: add xen config fragments to XEN HYPERVISOR sections
xen: remove XEN_SCRUB_PAGES in xen.config
xen/pciback: Fix comment typo
xen/xenbus: fix return type in xenbus_file_read()
xen-blkfront: Apply 'feature_persistent' parameter when connect
xen-blkback: Apply 'feature_persistent' parameter when connect
xen-blkback: fix persistent grants negotiation
x86/xen: Add support for HVMOP_set_evtchn_upcall_vector

+116 -36
+1 -1
Documentation/ABI/testing/sysfs-driver-xen-blkback
··· 42 42 Contact: Maximilian Heyne <mheyne@amazon.de> 43 43 Description: 44 44 Whether to enable the persistent grants feature or not. Note 45 - that this option only takes effect on newly created backends. 45 + that this option only takes effect on newly connected backends. 46 46 The default is Y (enable).
+1 -1
Documentation/ABI/testing/sysfs-driver-xen-blkfront
··· 15 15 Contact: Maximilian Heyne <mheyne@amazon.de> 16 16 Description: 17 17 Whether to enable the persistent grants feature or not. Note 18 - that this option only takes effect on newly created frontends. 18 + that this option only takes effect on newly connected frontends. 19 19 The default is Y (enable).
+2
MAINTAINERS
··· 22200 22200 F: drivers/xen/ 22201 22201 F: include/uapi/xen/ 22202 22202 F: include/xen/ 22203 + F: kernel/configs/xen.config 22203 22204 22204 22205 XEN HYPERVISOR X86 22205 22206 M: Juergen Gross <jgross@suse.com> 22206 22207 R: Boris Ostrovsky <boris.ostrovsky@oracle.com> 22207 22208 L: xen-devel@lists.xenproject.org (moderated for non-subscribers) 22208 22209 S: Supported 22210 + F: arch/x86/configs/xen.config 22209 22211 F: arch/x86/include/asm/pvclock-abi.h 22210 22212 F: arch/x86/include/asm/xen/ 22211 22213 F: arch/x86/platform/pvh/
+2
arch/x86/include/asm/xen/cpuid.h
··· 107 107 * ID field from 8 to 15 bits, allowing to target APIC IDs up 32768. 108 108 */ 109 109 #define XEN_HVM_CPUID_EXT_DEST_ID (1u << 5) 110 + /* Per-vCPU event channel upcalls */ 111 + #define XEN_HVM_CPUID_UPCALL_VECTOR (1u << 6) 110 112 111 113 /* 112 114 * Leaf 6 (0x40000x05)
+2 -1
arch/x86/include/asm/xen/events.h
··· 23 23 /* No need for a barrier -- XCHG is a barrier on x86. */ 24 24 #define xchg_xen_ulong(ptr, val) xchg((ptr), (val)) 25 25 26 - extern int xen_have_vector_callback; 26 + extern bool xen_have_vector_callback; 27 27 28 28 /* 29 29 * Events delivered via platform PCI interrupts are always ··· 34 34 return (!xen_hvm_domain() || xen_have_vector_callback); 35 35 } 36 36 37 + extern bool xen_percpu_upcall; 37 38 #endif /* _ASM_X86_XEN_EVENTS_H */
+1 -1
arch/x86/xen/enlighten.c
··· 51 51 52 52 struct shared_info xen_dummy_shared_info; 53 53 54 - __read_mostly int xen_have_vector_callback; 54 + __read_mostly bool xen_have_vector_callback = true; 55 55 EXPORT_SYMBOL_GPL(xen_have_vector_callback); 56 56 57 57 /*
+18 -6
arch/x86/xen/enlighten_hvm.c
··· 8 8 9 9 #include <xen/features.h> 10 10 #include <xen/events.h> 11 + #include <xen/hvm.h> 12 + #include <xen/interface/hvm/hvm_op.h> 11 13 #include <xen/interface/memory.h> 12 14 13 15 #include <asm/apic.h> ··· 32 30 #include "smp.h" 33 31 34 32 static unsigned long shared_info_pfn; 33 + 34 + __ro_after_init bool xen_percpu_upcall; 35 + EXPORT_SYMBOL_GPL(xen_percpu_upcall); 35 36 36 37 void xen_hvm_init_shared_info(void) 37 38 { ··· 131 126 { 132 127 struct pt_regs *old_regs = set_irq_regs(regs); 133 128 129 + if (xen_percpu_upcall) 130 + ack_APIC_irq(); 131 + 134 132 inc_irq_stat(irq_hv_callback_count); 135 133 136 134 xen_hvm_evtchn_do_upcall(); ··· 177 169 if (!xen_have_vector_callback) 178 170 return 0; 179 171 172 + if (xen_percpu_upcall) { 173 + rc = xen_set_upcall_vector(cpu); 174 + if (rc) { 175 + WARN(1, "HVMOP_set_evtchn_upcall_vector" 176 + " for CPU %d failed: %d\n", cpu, rc); 177 + return rc; 178 + } 179 + } 180 + 180 181 if (xen_feature(XENFEAT_hvm_safe_pvclock)) 181 182 xen_setup_timer(cpu); 182 183 ··· 205 188 xen_teardown_timer(cpu); 206 189 return 0; 207 190 } 208 - 209 - static bool no_vector_callback __initdata; 210 191 211 192 static void __init xen_hvm_guest_init(void) 212 193 { ··· 227 212 xen_vcpu_info_reset(0); 228 213 229 214 xen_panic_handler_init(); 230 - 231 - if (!no_vector_callback && xen_feature(XENFEAT_hvm_callback_vector)) 232 - xen_have_vector_callback = 1; 233 215 234 216 xen_hvm_smp_init(); 235 217 WARN_ON(xen_cpuhp_setup(xen_cpu_up_prepare_hvm, xen_cpu_dead_hvm)); ··· 253 241 254 242 static __init int xen_parse_no_vector_callback(char *arg) 255 243 { 256 - no_vector_callback = true; 244 + xen_have_vector_callback = false; 257 245 return 0; 258 246 } 259 247 early_param("xen_no_vector_callback", xen_parse_no_vector_callback);
+9 -1
arch/x86/xen/suspend_hvm.c
··· 5 5 #include <xen/hvm.h> 6 6 #include <xen/features.h> 7 7 #include <xen/interface/features.h> 8 + #include <xen/events.h> 8 9 9 10 #include "xen-ops.h" 10 11 ··· 15 14 xen_hvm_init_shared_info(); 16 15 xen_vcpu_restore(); 17 16 } 18 - xen_setup_callback_vector(); 17 + if (xen_percpu_upcall) { 18 + unsigned int cpu; 19 + 20 + for_each_online_cpu(cpu) 21 + BUG_ON(xen_set_upcall_vector(cpu)); 22 + } else { 23 + xen_setup_callback_vector(); 24 + } 19 25 xen_unplug_emulated_devices(); 20 26 }
+8 -12
drivers/block/xen-blkback/xenbus.c
··· 157 157 return 0; 158 158 } 159 159 160 + /* Enable the persistent grants feature. */ 161 + static bool feature_persistent = true; 162 + module_param(feature_persistent, bool, 0644); 163 + MODULE_PARM_DESC(feature_persistent, "Enables the persistent grants feature"); 164 + 160 165 static struct xen_blkif *xen_blkif_alloc(domid_t domid) 161 166 { 162 167 struct xen_blkif *blkif; ··· 477 472 vbd->bdev = NULL; 478 473 } 479 474 480 - /* Enable the persistent grants feature. */ 481 - static bool feature_persistent = true; 482 - module_param(feature_persistent, bool, 0644); 483 - MODULE_PARM_DESC(feature_persistent, 484 - "Enables the persistent grants feature"); 485 - 486 475 static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle, 487 476 unsigned major, unsigned minor, int readonly, 488 477 int cdrom) ··· 518 519 vbd->flush_support = true; 519 520 if (bdev_max_secure_erase_sectors(bdev)) 520 521 vbd->discard_secure = true; 521 - 522 - vbd->feature_gnt_persistent = feature_persistent; 523 522 524 523 pr_debug("Successful creation of handle=%04x (dom=%u)\n", 525 524 handle, blkif->domid); ··· 1084 1087 xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol); 1085 1088 return -ENOSYS; 1086 1089 } 1087 - if (blkif->vbd.feature_gnt_persistent) 1088 - blkif->vbd.feature_gnt_persistent = 1089 - xenbus_read_unsigned(dev->otherend, 1090 - "feature-persistent", 0); 1090 + 1091 + blkif->vbd.feature_gnt_persistent = feature_persistent && 1092 + xenbus_read_unsigned(dev->otherend, "feature-persistent", 0); 1091 1093 1092 1094 blkif->vbd.overflow_max_grants = 0; 1093 1095
+1 -3
drivers/block/xen-blkfront.c
··· 1988 1988 info->vdevice = vdevice; 1989 1989 info->connected = BLKIF_STATE_DISCONNECTED; 1990 1990 1991 - info->feature_persistent = feature_persistent; 1992 - 1993 1991 /* Front end dir is a number, which is used as the id. */ 1994 1992 info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0); 1995 1993 dev_set_drvdata(&dev->dev, info); ··· 2281 2283 if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0)) 2282 2284 blkfront_setup_discard(info); 2283 2285 2284 - if (info->feature_persistent) 2286 + if (feature_persistent) 2285 2287 info->feature_persistent = 2286 2288 !!xenbus_read_unsigned(info->xbdev->otherend, 2287 2289 "feature-persistent", 0);
+47 -6
drivers/xen/events/events_base.c
··· 45 45 #include <asm/irq.h> 46 46 #include <asm/io_apic.h> 47 47 #include <asm/i8259.h> 48 + #include <asm/xen/cpuid.h> 48 49 #include <asm/xen/pci.h> 49 50 #endif 50 51 #include <asm/sync_bitops.h> ··· 2185 2184 .irq_ack = ack_dynirq, 2186 2185 }; 2187 2186 2187 + #ifdef CONFIG_X86 2188 2188 #ifdef CONFIG_XEN_PVHVM 2189 2189 /* Vector callbacks are better than PCI interrupts to receive event 2190 2190 * channel notifications because we can receive vector callbacks on any ··· 2198 2196 callback_via = HVM_CALLBACK_VECTOR(HYPERVISOR_CALLBACK_VECTOR); 2199 2197 if (xen_set_callback_via(callback_via)) { 2200 2198 pr_err("Request for Xen HVM callback vector failed\n"); 2201 - xen_have_vector_callback = 0; 2199 + xen_have_vector_callback = false; 2202 2200 } 2203 2201 } 2202 + } 2203 + 2204 + /* 2205 + * Setup per-vCPU vector-type callbacks. If this setup is unavailable, 2206 + * fallback to the global vector-type callback. 2207 + */ 2208 + static __init void xen_init_setup_upcall_vector(void) 2209 + { 2210 + if (!xen_have_vector_callback) 2211 + return; 2212 + 2213 + if ((cpuid_eax(xen_cpuid_base() + 4) & XEN_HVM_CPUID_UPCALL_VECTOR) && 2214 + !xen_set_upcall_vector(0)) 2215 + xen_percpu_upcall = true; 2216 + else if (xen_feature(XENFEAT_hvm_callback_vector)) 2217 + xen_setup_callback_vector(); 2218 + else 2219 + xen_have_vector_callback = false; 2220 + } 2221 + 2222 + int xen_set_upcall_vector(unsigned int cpu) 2223 + { 2224 + int rc; 2225 + xen_hvm_evtchn_upcall_vector_t op = { 2226 + .vector = HYPERVISOR_CALLBACK_VECTOR, 2227 + .vcpu = per_cpu(xen_vcpu_id, cpu), 2228 + }; 2229 + 2230 + rc = HYPERVISOR_hvm_op(HVMOP_set_evtchn_upcall_vector, &op); 2231 + if (rc) 2232 + return rc; 2233 + 2234 + /* Trick toolstack to think we are enlightened. */ 2235 + if (!cpu) 2236 + rc = xen_set_callback_via(1); 2237 + 2238 + return rc; 2204 2239 } 2205 2240 2206 2241 static __init void xen_alloc_callback_vector(void) ··· 2250 2211 } 2251 2212 #else 2252 2213 void xen_setup_callback_vector(void) {} 2214 + static inline void xen_init_setup_upcall_vector(void) {} 2215 + int xen_set_upcall_vector(unsigned int cpu) {} 2253 2216 static inline void xen_alloc_callback_vector(void) {} 2254 - #endif 2217 + #endif /* CONFIG_XEN_PVHVM */ 2218 + #endif /* CONFIG_X86 */ 2255 2219 2256 2220 bool xen_fifo_events = true; 2257 2221 module_param_named(fifo_events, xen_fifo_events, bool, 0); ··· 2314 2272 if (xen_initial_domain()) 2315 2273 pci_xen_initial_domain(); 2316 2274 } 2317 - if (xen_feature(XENFEAT_hvm_callback_vector)) { 2318 - xen_setup_callback_vector(); 2319 - xen_alloc_callback_vector(); 2320 - } 2275 + xen_init_setup_upcall_vector(); 2276 + xen_alloc_callback_vector(); 2277 + 2321 2278 2322 2279 if (xen_hvm_domain()) { 2323 2280 native_init_IRQ();
+1 -1
drivers/xen/xen-pciback/pciback_ops.c
··· 159 159 return XEN_PCI_ERR_op_failed; 160 160 } 161 161 162 - /* The value the guest needs is actually the IDT vector, not the 162 + /* The value the guest needs is actually the IDT vector, not 163 163 * the local domain's IRQ number. */ 164 164 165 165 op->value = dev->irq ? xen_pirq_from_irq(dev->irq) : 0;
+2 -2
drivers/xen/xenbus/xenbus_dev_frontend.c
··· 128 128 { 129 129 struct xenbus_file_priv *u = filp->private_data; 130 130 struct read_buffer *rb; 131 - unsigned i; 131 + ssize_t i; 132 132 int ret; 133 133 134 134 mutex_lock(&u->reply_mutex); ··· 148 148 rb = list_entry(u->read_buffers.next, struct read_buffer, list); 149 149 i = 0; 150 150 while (i < len) { 151 - unsigned sz = min((unsigned)len - i, rb->len - rb->cons); 151 + size_t sz = min_t(size_t, len - i, rb->len - rb->cons); 152 152 153 153 ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz); 154 154
+2
include/xen/hvm.h
··· 60 60 61 61 void xen_setup_callback_vector(void); 62 62 63 + int xen_set_upcall_vector(unsigned int cpu); 64 + 63 65 #endif /* XEN_HVM_H__ */
+19
include/xen/interface/hvm/hvm_op.h
··· 46 46 }; 47 47 DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_get_mem_type); 48 48 49 + #if defined(__i386__) || defined(__x86_64__) 50 + 51 + /* 52 + * HVMOP_set_evtchn_upcall_vector: Set a <vector> that should be used for event 53 + * channel upcalls on the specified <vcpu>. If set, 54 + * this vector will be used in preference to the 55 + * domain global callback via (see 56 + * HVM_PARAM_CALLBACK_IRQ). 57 + */ 58 + #define HVMOP_set_evtchn_upcall_vector 23 59 + struct xen_hvm_evtchn_upcall_vector { 60 + uint32_t vcpu; 61 + uint8_t vector; 62 + }; 63 + typedef struct xen_hvm_evtchn_upcall_vector xen_hvm_evtchn_upcall_vector_t; 64 + DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_evtchn_upcall_vector_t); 65 + 66 + #endif /* defined(__i386__) || defined(__x86_64__) */ 67 + 49 68 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
-1
kernel/configs/xen.config
··· 34 34 CONFIG_XEN_SCSI_FRONTEND=m 35 35 # others 36 36 CONFIG_XEN_BALLOON=y 37 - CONFIG_XEN_SCRUB_PAGES=y 38 37 CONFIG_XEN_DEV_EVTCHN=m 39 38 CONFIG_XEN_BLKDEV_FRONTEND=m 40 39 CONFIG_XEN_NETDEV_FRONTEND=m