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

xen: allow pv-only hypercalls only with CONFIG_XEN_PV

Put the definitions of the hypercalls usable only by pv guests inside
CONFIG_XEN_PV sections.

On Arm two dummy functions related to pv hypercalls can be removed.

While at it remove the no longer supported tmem hypercall definition.

Signed-off-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20211028081221.2475-3-jgross@suse.com
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

authored by

Juergen Gross and committed by
Boris Ostrovsky
ee1f9d19 d99bb72a

+122 -147
-1
arch/arm/xen/enlighten.c
··· 442 442 EXPORT_SYMBOL_GPL(HYPERVISOR_memory_op); 443 443 EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); 444 444 EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); 445 - EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op); 446 445 EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op_raw); 447 446 EXPORT_SYMBOL_GPL(HYPERVISOR_multicall); 448 447 EXPORT_SYMBOL_GPL(HYPERVISOR_vm_assist);
-1
arch/arm/xen/hypercall.S
··· 88 88 HYPERCALL2(memory_op); 89 89 HYPERCALL2(physdev_op); 90 90 HYPERCALL3(vcpu_op); 91 - HYPERCALL1(tmem_op); 92 91 HYPERCALL1(platform_op_raw); 93 92 HYPERCALL2(multicall); 94 93 HYPERCALL2(vm_assist);
-1
arch/arm64/xen/hypercall.S
··· 80 80 HYPERCALL2(memory_op); 81 81 HYPERCALL2(physdev_op); 82 82 HYPERCALL3(vcpu_op); 83 - HYPERCALL1(tmem_op); 84 83 HYPERCALL1(platform_op_raw); 85 84 HYPERCALL2(multicall); 86 85 HYPERCALL2(vm_assist);
+122 -129
arch/x86/include/asm/xen/hypercall.h
··· 248 248 return res; 249 249 } 250 250 251 + #ifdef CONFIG_XEN_PV 251 252 static inline int 252 253 HYPERVISOR_set_trap_table(struct trap_info *table) 253 254 { ··· 282 281 } 283 282 284 283 static inline int 285 - HYPERVISOR_sched_op(int cmd, void *arg) 286 - { 287 - return _hypercall2(int, sched_op, cmd, arg); 288 - } 289 - 290 - static inline long 291 - HYPERVISOR_set_timer_op(u64 timeout) 292 - { 293 - unsigned long timeout_hi = (unsigned long)(timeout>>32); 294 - unsigned long timeout_lo = (unsigned long)timeout; 295 - return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi); 296 - } 297 - 298 - static inline int 299 - HYPERVISOR_mca(struct xen_mc *mc_op) 300 - { 301 - mc_op->interface_version = XEN_MCA_INTERFACE_VERSION; 302 - return _hypercall1(int, mca, mc_op); 303 - } 304 - 305 - static inline int 306 - HYPERVISOR_platform_op(struct xen_platform_op *op) 307 - { 308 - op->interface_version = XENPF_INTERFACE_VERSION; 309 - return _hypercall1(int, platform_op, op); 310 - } 311 - 312 - static __always_inline int 313 284 HYPERVISOR_set_debugreg(int reg, unsigned long value) 314 285 { 315 286 return _hypercall2(int, set_debugreg, reg, value); 316 287 } 317 288 318 - static __always_inline unsigned long 289 + static inline unsigned long 319 290 HYPERVISOR_get_debugreg(int reg) 320 291 { 321 292 return _hypercall1(unsigned long, get_debugreg, reg); ··· 299 326 return _hypercall2(int, update_descriptor, ma, desc); 300 327 } 301 328 302 - static inline long 303 - HYPERVISOR_memory_op(unsigned int cmd, void *arg) 304 - { 305 - return _hypercall2(long, memory_op, cmd, arg); 306 - } 307 - 308 - static inline int 309 - HYPERVISOR_multicall(void *call_list, uint32_t nr_calls) 310 - { 311 - return _hypercall2(int, multicall, call_list, nr_calls); 312 - } 313 - 314 329 static inline int 315 330 HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val, 316 331 unsigned long flags) ··· 307 346 } 308 347 309 348 static inline int 310 - HYPERVISOR_event_channel_op(int cmd, void *arg) 311 - { 312 - return _hypercall2(int, event_channel_op, cmd, arg); 313 - } 314 - 315 - static __always_inline int 316 - HYPERVISOR_xen_version(int cmd, void *arg) 317 - { 318 - return _hypercall2(int, xen_version, cmd, arg); 319 - } 320 - 321 - static inline int 322 - HYPERVISOR_console_io(int cmd, int count, char *str) 323 - { 324 - return _hypercall3(int, console_io, cmd, count, str); 325 - } 326 - 327 - static inline int 328 - HYPERVISOR_physdev_op(int cmd, void *arg) 329 - { 330 - return _hypercall2(int, physdev_op, cmd, arg); 331 - } 332 - 333 - static inline int 334 - HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count) 335 - { 336 - return _hypercall3(int, grant_table_op, cmd, uop, count); 337 - } 338 - 339 - static inline int 340 - HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type) 341 - { 342 - return _hypercall2(int, vm_assist, cmd, type); 343 - } 344 - 345 - static inline int 346 - HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args) 347 - { 348 - return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); 349 - } 350 - 351 - #ifdef CONFIG_X86_64 352 - static inline int 353 349 HYPERVISOR_set_segment_base(int reg, unsigned long value) 354 350 { 355 351 return _hypercall2(int, set_segment_base, reg, value); 356 - } 357 - #endif 358 - 359 - static inline int 360 - HYPERVISOR_suspend(unsigned long start_info_mfn) 361 - { 362 - struct sched_shutdown r = { .reason = SHUTDOWN_suspend }; 363 - 364 - /* 365 - * For a PV guest the tools require that the start_info mfn be 366 - * present in rdx/edx when the hypercall is made. Per the 367 - * hypercall calling convention this is the third hypercall 368 - * argument, which is start_info_mfn here. 369 - */ 370 - return _hypercall3(int, sched_op, SCHEDOP_shutdown, &r, start_info_mfn); 371 - } 372 - 373 - static inline unsigned long __must_check 374 - HYPERVISOR_hvm_op(int op, void *arg) 375 - { 376 - return _hypercall2(unsigned long, hvm_op, op, arg); 377 - } 378 - 379 - static inline int 380 - HYPERVISOR_tmem_op( 381 - struct tmem_op *op) 382 - { 383 - return _hypercall1(int, tmem_op, op); 384 - } 385 - 386 - static inline int 387 - HYPERVISOR_xenpmu_op(unsigned int op, void *arg) 388 - { 389 - return _hypercall2(int, xenpmu_op, op, arg); 390 - } 391 - 392 - static inline int 393 - HYPERVISOR_dm_op( 394 - domid_t dom, unsigned int nr_bufs, struct xen_dm_op_buf *bufs) 395 - { 396 - int ret; 397 - __xen_stac(); 398 - ret = _hypercall3(int, dm_op, dom, nr_bufs, bufs); 399 - __xen_clac(); 400 - return ret; 401 352 } 402 353 403 354 static inline void ··· 379 506 mcl->args[1] = esp; 380 507 381 508 trace_xen_mc_entry(mcl, 2); 509 + } 510 + #endif 511 + 512 + static inline int 513 + HYPERVISOR_sched_op(int cmd, void *arg) 514 + { 515 + return _hypercall2(int, sched_op, cmd, arg); 516 + } 517 + 518 + static inline long 519 + HYPERVISOR_set_timer_op(u64 timeout) 520 + { 521 + unsigned long timeout_hi = (unsigned long)(timeout>>32); 522 + unsigned long timeout_lo = (unsigned long)timeout; 523 + return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi); 524 + } 525 + 526 + static inline int 527 + HYPERVISOR_mca(struct xen_mc *mc_op) 528 + { 529 + mc_op->interface_version = XEN_MCA_INTERFACE_VERSION; 530 + return _hypercall1(int, mca, mc_op); 531 + } 532 + 533 + static inline int 534 + HYPERVISOR_platform_op(struct xen_platform_op *op) 535 + { 536 + op->interface_version = XENPF_INTERFACE_VERSION; 537 + return _hypercall1(int, platform_op, op); 538 + } 539 + 540 + static inline long 541 + HYPERVISOR_memory_op(unsigned int cmd, void *arg) 542 + { 543 + return _hypercall2(long, memory_op, cmd, arg); 544 + } 545 + 546 + static inline int 547 + HYPERVISOR_multicall(void *call_list, uint32_t nr_calls) 548 + { 549 + return _hypercall2(int, multicall, call_list, nr_calls); 550 + } 551 + 552 + static inline int 553 + HYPERVISOR_event_channel_op(int cmd, void *arg) 554 + { 555 + return _hypercall2(int, event_channel_op, cmd, arg); 556 + } 557 + 558 + static __always_inline int 559 + HYPERVISOR_xen_version(int cmd, void *arg) 560 + { 561 + return _hypercall2(int, xen_version, cmd, arg); 562 + } 563 + 564 + static inline int 565 + HYPERVISOR_console_io(int cmd, int count, char *str) 566 + { 567 + return _hypercall3(int, console_io, cmd, count, str); 568 + } 569 + 570 + static inline int 571 + HYPERVISOR_physdev_op(int cmd, void *arg) 572 + { 573 + return _hypercall2(int, physdev_op, cmd, arg); 574 + } 575 + 576 + static inline int 577 + HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count) 578 + { 579 + return _hypercall3(int, grant_table_op, cmd, uop, count); 580 + } 581 + 582 + static inline int 583 + HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type) 584 + { 585 + return _hypercall2(int, vm_assist, cmd, type); 586 + } 587 + 588 + static inline int 589 + HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args) 590 + { 591 + return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); 592 + } 593 + 594 + static inline int 595 + HYPERVISOR_suspend(unsigned long start_info_mfn) 596 + { 597 + struct sched_shutdown r = { .reason = SHUTDOWN_suspend }; 598 + 599 + /* 600 + * For a PV guest the tools require that the start_info mfn be 601 + * present in rdx/edx when the hypercall is made. Per the 602 + * hypercall calling convention this is the third hypercall 603 + * argument, which is start_info_mfn here. 604 + */ 605 + return _hypercall3(int, sched_op, SCHEDOP_shutdown, &r, start_info_mfn); 606 + } 607 + 608 + static inline unsigned long __must_check 609 + HYPERVISOR_hvm_op(int op, void *arg) 610 + { 611 + return _hypercall2(unsigned long, hvm_op, op, arg); 612 + } 613 + 614 + static inline int 615 + HYPERVISOR_xenpmu_op(unsigned int op, void *arg) 616 + { 617 + return _hypercall2(int, xenpmu_op, op, arg); 618 + } 619 + 620 + static inline int 621 + HYPERVISOR_dm_op( 622 + domid_t dom, unsigned int nr_bufs, struct xen_dm_op_buf *bufs) 623 + { 624 + int ret; 625 + __xen_stac(); 626 + ret = _hypercall3(int, dm_op, dom, nr_bufs, bufs); 627 + __xen_clac(); 628 + return ret; 382 629 } 383 630 384 631 #endif /* _ASM_X86_XEN_HYPERCALL_H */
-15
include/xen/arm/hypercall.h
··· 53 53 int HYPERVISOR_memory_op(unsigned int cmd, void *arg); 54 54 int HYPERVISOR_physdev_op(int cmd, void *arg); 55 55 int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args); 56 - int HYPERVISOR_tmem_op(void *arg); 57 56 int HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type); 58 57 int HYPERVISOR_dm_op(domid_t domid, unsigned int nr_bufs, 59 58 struct xen_dm_op_buf *bufs); ··· 71 72 72 73 /* start_info_mfn is unused on ARM */ 73 74 return HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); 74 - } 75 - 76 - static inline void 77 - MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, 78 - unsigned int new_val, unsigned long flags) 79 - { 80 - BUG(); 81 - } 82 - 83 - static inline void 84 - MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req, 85 - int count, int *success_count, domid_t domid) 86 - { 87 - BUG(); 88 75 } 89 76 90 77 #endif /* _ASM_ARM_XEN_HYPERCALL_H */