Skip to content

Commit

Permalink
Merge tag 'for-linus-6.0-rc1-tag' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/xen/tip

Pull xen updates from Juergen Gross:

 - a series fine tuning virtio support for Xen guests, including removal
   the now again unused "platform_has()" feature.

 - a fix for host admin triggered reboot of Xen guests

 - a simple spelling fix

* tag 'for-linus-6.0-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen: don't require virtio with grants for non-PV guests
  kernel: remove platform_has() infrastructure
  virtio: replace restricted mem access flag with callback
  xen: Fix spelling mistake
  xen/manage: Use orderly_reboot() to reboot
  • Loading branch information
torvalds committed Aug 4, 2022
2 parents 7c5c3a6 + 251e90e commit 7447691
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 84 deletions.
8 changes: 0 additions & 8 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -16121,14 +16121,6 @@ S: Maintained
F: Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.yaml
F: drivers/iio/chemical/pms7003.c

PLATFORM FEATURE INFRASTRUCTURE
M: Juergen Gross <[email protected]>
S: Maintained
F: arch/*/include/asm/platform-feature.h
F: include/asm-generic/platform-feature.h
F: include/linux/platform-feature.h
F: kernel/platform-feature.c

PLDMFW LIBRARY
M: Jacob Keller <[email protected]>
S: Maintained
Expand Down
4 changes: 3 additions & 1 deletion arch/arm/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/timekeeping.h>
#include <linux/timekeeper_internal.h>
#include <linux/acpi.h>
#include <linux/virtio_anchor.h>

#include <linux/mm.h>

Expand Down Expand Up @@ -443,7 +444,8 @@ static int __init xen_guest_init(void)
if (!xen_domain())
return 0;

xen_set_restricted_virtio_memory_access();
if (IS_ENABLED(CONFIG_XEN_VIRTIO))
virtio_set_mem_acc_cb(xen_virtio_mem_acc);

if (!acpi_disabled)
xen_acpi_guest_init();
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <linux/cma.h>
#include <linux/gfp.h>
#include <linux/dma-direct.h>
#include <linux/platform-feature.h>
#include <asm/processor.h>
#include <linux/uaccess.h>
#include <asm/pgalloc.h>
Expand All @@ -48,6 +47,7 @@
#include <asm/kasan.h>
#include <asm/dma-mapping.h>
#include <asm/uv.h>
#include <linux/virtio_anchor.h>
#include <linux/virtio_config.h>

pgd_t swapper_pg_dir[PTRS_PER_PGD] __section(".bss..swapper_pg_dir");
Expand Down Expand Up @@ -175,7 +175,7 @@ static void pv_init(void)
if (!is_prot_virt_guest())
return;

platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS);
virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);

/* make sure bounce buffers are shared */
swiotlb_init(true, SWIOTLB_FORCE | SWIOTLB_VERBOSE);
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/mm/mem_encrypt_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <linux/bitops.h>
#include <linux/dma-mapping.h>
#include <linux/virtio_config.h>
#include <linux/virtio_anchor.h>
#include <linux/cc_platform.h>
#include <linux/platform-feature.h>

#include <asm/tlbflush.h>
#include <asm/fixmap.h>
Expand Down Expand Up @@ -245,7 +245,7 @@ void __init sev_setup_arch(void)
swiotlb_adjust_size(size);

/* Set restricted memory access for virtio. */
platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS);
virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);
}

static unsigned long pg_level_to_pfn(int level, pte_t *kpte, pgprot_t *ret_prot)
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/xen/enlighten_hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/cpu.h>
#include <linux/kexec.h>
#include <linux/memblock.h>
#include <linux/virtio_anchor.h>

#include <xen/features.h>
#include <xen/events.h>
Expand Down Expand Up @@ -195,7 +196,8 @@ static void __init xen_hvm_guest_init(void)
if (xen_pv_domain())
return;

xen_set_restricted_virtio_memory_access();
if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);

init_hvm_pv_info();

Expand Down
5 changes: 4 additions & 1 deletion arch/x86/xen/enlighten_pv.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/gfp.h>
#include <linux/edd.h>
#include <linux/reboot.h>
#include <linux/virtio_anchor.h>

#include <xen/xen.h>
#include <xen/events.h>
Expand Down Expand Up @@ -109,7 +110,9 @@ static DEFINE_PER_CPU(struct tls_descs, shadow_tls_desc);

static void __init xen_pv_init_platform(void)
{
xen_set_restricted_virtio_memory_access();
/* PV guests can't operate virtio devices without grants. */
if (IS_ENABLED(CONFIG_XEN_VIRTIO))
virtio_set_mem_acc_cb(virtio_require_restricted_mem_acc);

populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));

Expand Down
4 changes: 4 additions & 0 deletions drivers/virtio/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-only
config VIRTIO_ANCHOR
bool

config VIRTIO
tristate
select VIRTIO_ANCHOR
help
This option is selected by any driver which implements the virtio
bus, such as CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_MMIO, CONFIG_RPMSG
Expand Down
1 change: 1 addition & 0 deletions drivers/virtio/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_VIRTIO) += virtio.o virtio_ring.o
obj-$(CONFIG_VIRTIO_ANCHOR) += virtio_anchor.o
obj-$(CONFIG_VIRTIO_PCI_LIB) += virtio_pci_modern_dev.o
obj-$(CONFIG_VIRTIO_PCI_LIB_LEGACY) += virtio_pci_legacy_dev.o
obj-$(CONFIG_VIRTIO_MMIO) += virtio_mmio.o
Expand Down
4 changes: 2 additions & 2 deletions drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include <linux/virtio.h>
#include <linux/spinlock.h>
#include <linux/virtio_config.h>
#include <linux/virtio_anchor.h>
#include <linux/module.h>
#include <linux/idr.h>
#include <linux/of.h>
#include <linux/platform-feature.h>
#include <uapi/linux/virtio_ids.h>

/* Unique numbering for virtio devices. */
Expand Down Expand Up @@ -174,7 +174,7 @@ static int virtio_features_ok(struct virtio_device *dev)

might_sleep();

if (platform_has(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS)) {
if (virtio_check_mem_acc_cb(dev)) {
if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) {
dev_warn(&dev->dev,
"device must provide VIRTIO_F_VERSION_1\n");
Expand Down
18 changes: 18 additions & 0 deletions drivers/virtio/virtio_anchor.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/virtio.h>
#include <linux/virtio_anchor.h>

bool virtio_require_restricted_mem_acc(struct virtio_device *dev)
{
return true;
}
EXPORT_SYMBOL_GPL(virtio_require_restricted_mem_acc);

static bool virtio_no_restricted_mem_acc(struct virtio_device *dev)
{
return false;
}

bool (*virtio_check_mem_acc_cb)(struct virtio_device *dev) =
virtio_no_restricted_mem_acc;
EXPORT_SYMBOL_GPL(virtio_check_mem_acc_cb);
9 changes: 9 additions & 0 deletions drivers/xen/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,13 @@ config XEN_VIRTIO

If in doubt, say n.

config XEN_VIRTIO_FORCE_GRANT
bool "Require Xen virtio support to use grants"
depends on XEN_VIRTIO
help
Require virtio for Xen guests to use grant mappings.
This will avoid the need to give the backend the right to map all
of the guest memory. This will need support on the backend side
(e.g. qemu or kernel, depending on the virtio device types used).

endmenu
10 changes: 10 additions & 0 deletions drivers/xen/grant-dma-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <linux/of.h>
#include <linux/pfn.h>
#include <linux/xarray.h>
#include <linux/virtio_anchor.h>
#include <linux/virtio.h>
#include <xen/xen.h>
#include <xen/xen-ops.h>
#include <xen/grant_table.h>
Expand Down Expand Up @@ -287,6 +289,14 @@ bool xen_is_grant_dma_device(struct device *dev)
return has_iommu;
}

bool xen_virtio_mem_acc(struct virtio_device *dev)
{
if (IS_ENABLED(CONFIG_XEN_VIRTIO_FORCE_GRANT))
return true;

return xen_is_grant_dma_device(dev->dev.parent);
}

void xen_grant_setup_dma_ops(struct device *dev)
{
struct xen_grant_dma_data *data;
Expand Down
2 changes: 1 addition & 1 deletion drivers/xen/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static void do_poweroff(void)
static void do_reboot(void)
{
shutting_down = SHUTDOWN_POWEROFF; /* ? */
ctrl_alt_del();
orderly_reboot();
}

static struct shutdown_handler shutdown_handlers[] = {
Expand Down
4 changes: 2 additions & 2 deletions drivers/xen/xen-front-pgdir-shbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ EXPORT_SYMBOL_GPL(xen_front_pgdir_shbuf_get_dir_start);
* shared by the frontend itself) or map the provided granted
* references onto the backing storage (buf->pages).
*
* \param buf shared buffer which grants to be maped.
* \param buf shared buffer which grants to be mapped.
* \return zero on success or a negative number on failure.
*/
int xen_front_pgdir_shbuf_map(struct xen_front_pgdir_shbuf *buf)
Expand All @@ -110,7 +110,7 @@ EXPORT_SYMBOL_GPL(xen_front_pgdir_shbuf_map);
* shared by the frontend itself) or unmap the provided granted
* references.
*
* \param buf shared buffer which grants to be unmaped.
* \param buf shared buffer which grants to be unmapped.
* \return zero on success or a negative number on failure.
*/
int xen_front_pgdir_shbuf_unmap(struct xen_front_pgdir_shbuf *buf)
Expand Down
1 change: 0 additions & 1 deletion include/asm-generic/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ mandatory-y += msi.h
mandatory-y += pci.h
mandatory-y += percpu.h
mandatory-y += pgalloc.h
mandatory-y += platform-feature.h
mandatory-y += preempt.h
mandatory-y += rwonce.h
mandatory-y += sections.h
Expand Down
8 changes: 0 additions & 8 deletions include/asm-generic/platform-feature.h

This file was deleted.

19 changes: 0 additions & 19 deletions include/linux/platform-feature.h

This file was deleted.

19 changes: 19 additions & 0 deletions include/linux/virtio_anchor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_VIRTIO_ANCHOR_H
#define _LINUX_VIRTIO_ANCHOR_H

#ifdef CONFIG_VIRTIO_ANCHOR
struct virtio_device;

bool virtio_require_restricted_mem_acc(struct virtio_device *dev);
extern bool (*virtio_check_mem_acc_cb)(struct virtio_device *dev);

static inline void virtio_set_mem_acc_cb(bool (*func)(struct virtio_device *))
{
virtio_check_mem_acc_cb = func;
}
#else
#define virtio_set_mem_acc_cb(func) do { } while (0)
#endif

#endif /* _LINUX_VIRTIO_ANCHOR_H */
9 changes: 9 additions & 0 deletions include/xen/xen-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/percpu.h>
#include <linux/notifier.h>
#include <linux/efi.h>
#include <linux/virtio_anchor.h>
#include <xen/features.h>
#include <asm/xen/interface.h>
#include <xen/interface/vcpu.h>
Expand Down Expand Up @@ -217,6 +218,7 @@ static inline void xen_preemptible_hcall_end(void) { }
#ifdef CONFIG_XEN_GRANT_DMA_OPS
void xen_grant_setup_dma_ops(struct device *dev);
bool xen_is_grant_dma_device(struct device *dev);
bool xen_virtio_mem_acc(struct virtio_device *dev);
#else
static inline void xen_grant_setup_dma_ops(struct device *dev)
{
Expand All @@ -225,6 +227,13 @@ static inline bool xen_is_grant_dma_device(struct device *dev)
{
return false;
}

struct virtio_device;

static inline bool xen_virtio_mem_acc(struct virtio_device *dev)
{
return false;
}
#endif /* CONFIG_XEN_GRANT_DMA_OPS */

#endif /* INCLUDE_XEN_OPS_H */
8 changes: 0 additions & 8 deletions include/xen/xen.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
extern u64 xen_saved_max_mem_size;
#endif

#include <linux/platform-feature.h>

static inline void xen_set_restricted_virtio_memory_access(void)
{
if (IS_ENABLED(CONFIG_XEN_VIRTIO) && xen_domain())
platform_set(PLATFORM_VIRTIO_RESTRICTED_MEM_ACCESS);
}

#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
Expand Down
2 changes: 1 addition & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ obj-y = fork.o exec_domain.o panic.o \
cpu.o exit.o softirq.o resource.o \
sysctl.o capability.o ptrace.o user.o \
signal.o sys.o umh.o workqueue.o pid.o task_work.o \
extable.o params.o platform-feature.o \
extable.o params.o \
kthread.o sys_ni.o nsproxy.o \
notifier.o ksysfs.o cred.o reboot.o \
async.o range.o smpboot.o ucount.o regset.o
Expand Down
27 changes: 0 additions & 27 deletions kernel/platform-feature.c

This file was deleted.

0 comments on commit 7447691

Please sign in to comment.