diff options
| -rw-r--r-- | Documentation/ABI/stable/sysfs-devices-system-xen_memory | 9 | ||||
| -rw-r--r-- | Documentation/admin-guide/kernel-parameters.txt | 6 | ||||
| -rw-r--r-- | drivers/xen/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/xen/mem-reservation.c | 4 | ||||
| -rw-r--r-- | drivers/xen/xen-balloon.c | 3 | ||||
| -rw-r--r-- | include/xen/mem-reservation.h | 7 |
6 files changed, 33 insertions, 6 deletions
diff --git a/Documentation/ABI/stable/sysfs-devices-system-xen_memory b/Documentation/ABI/stable/sysfs-devices-system-xen_memory index caa311d59ac1..6d83f95a8a8e 100644 --- a/Documentation/ABI/stable/sysfs-devices-system-xen_memory +++ b/Documentation/ABI/stable/sysfs-devices-system-xen_memory | |||
| @@ -75,3 +75,12 @@ Contact: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | |||
| 75 | Description: | 75 | Description: |
| 76 | Amount (in KiB) of low (or normal) memory in the | 76 | Amount (in KiB) of low (or normal) memory in the |
| 77 | balloon. | 77 | balloon. |
| 78 | |||
| 79 | What: /sys/devices/system/xen_memory/xen_memory0/scrub_pages | ||
| 80 | Date: September 2018 | ||
| 81 | KernelVersion: 4.20 | ||
| 82 | Contact: xen-devel@lists.xenproject.org | ||
| 83 | Description: | ||
| 84 | Control scrubbing pages before returning them to Xen for others domains | ||
| 85 | use. Can be set with xen_scrub_pages cmdline | ||
| 86 | parameter. Default value controlled with CONFIG_XEN_SCRUB_PAGES_DEFAULT. | ||
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 64a3bf54b974..92eb1f42240d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
| @@ -5000,6 +5000,12 @@ | |||
| 5000 | Disables the PV optimizations forcing the HVM guest to | 5000 | Disables the PV optimizations forcing the HVM guest to |
| 5001 | run as generic HVM guest with no PV drivers. | 5001 | run as generic HVM guest with no PV drivers. |
| 5002 | 5002 | ||
| 5003 | xen_scrub_pages= [XEN] | ||
| 5004 | Boolean option to control scrubbing pages before giving them back | ||
| 5005 | to Xen, for use by other domains. Can be also changed at runtime | ||
| 5006 | with /sys/devices/system/xen_memory/xen_memory0/scrub_pages. | ||
| 5007 | Default value controlled with CONFIG_XEN_SCRUB_PAGES_DEFAULT. | ||
| 5008 | |||
| 5003 | xirc2ps_cs= [NET,PCMCIA] | 5009 | xirc2ps_cs= [NET,PCMCIA] |
| 5004 | Format: | 5010 | Format: |
| 5005 | <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] | 5011 | <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] |
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index b459edfacff3..90d387b50ab7 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
| @@ -79,15 +79,19 @@ config XEN_BALLOON_MEMORY_HOTPLUG_LIMIT | |||
| 79 | This value is used to allocate enough space in internal | 79 | This value is used to allocate enough space in internal |
| 80 | tables needed for physical memory administration. | 80 | tables needed for physical memory administration. |
| 81 | 81 | ||
| 82 | config XEN_SCRUB_PAGES | 82 | config XEN_SCRUB_PAGES_DEFAULT |
| 83 | bool "Scrub pages before returning them to system" | 83 | bool "Scrub pages before returning them to system by default" |
| 84 | depends on XEN_BALLOON | 84 | depends on XEN_BALLOON |
| 85 | default y | 85 | default y |
| 86 | help | 86 | help |
| 87 | Scrub pages before returning them to the system for reuse by | 87 | Scrub pages before returning them to the system for reuse by |
| 88 | other domains. This makes sure that any confidential data | 88 | other domains. This makes sure that any confidential data |
| 89 | is not accidentally visible to other domains. Is it more | 89 | is not accidentally visible to other domains. Is it more |
| 90 | secure, but slightly less efficient. | 90 | secure, but slightly less efficient. This can be controlled with |
| 91 | xen_scrub_pages=0 parameter and | ||
| 92 | /sys/devices/system/xen_memory/xen_memory0/scrub_pages. | ||
| 93 | This option only sets the default value. | ||
| 94 | |||
| 91 | If in doubt, say yes. | 95 | If in doubt, say yes. |
| 92 | 96 | ||
| 93 | config XEN_DEV_EVTCHN | 97 | config XEN_DEV_EVTCHN |
diff --git a/drivers/xen/mem-reservation.c b/drivers/xen/mem-reservation.c index 084799c6180e..3782cf070338 100644 --- a/drivers/xen/mem-reservation.c +++ b/drivers/xen/mem-reservation.c | |||
| @@ -14,6 +14,10 @@ | |||
| 14 | 14 | ||
| 15 | #include <xen/interface/memory.h> | 15 | #include <xen/interface/memory.h> |
| 16 | #include <xen/mem-reservation.h> | 16 | #include <xen/mem-reservation.h> |
| 17 | #include <linux/moduleparam.h> | ||
| 18 | |||
| 19 | bool __read_mostly xen_scrub_pages = IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT); | ||
| 20 | core_param(xen_scrub_pages, xen_scrub_pages, bool, 0); | ||
| 17 | 21 | ||
| 18 | /* | 22 | /* |
| 19 | * Use one extent per PAGE_SIZE to avoid to break down the page into | 23 | * Use one extent per PAGE_SIZE to avoid to break down the page into |
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index 294f35ce9e46..63c1494a8d73 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include <xen/xenbus.h> | 44 | #include <xen/xenbus.h> |
| 45 | #include <xen/features.h> | 45 | #include <xen/features.h> |
| 46 | #include <xen/page.h> | 46 | #include <xen/page.h> |
| 47 | #include <xen/mem-reservation.h> | ||
| 47 | 48 | ||
| 48 | #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) | 49 | #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) |
| 49 | 50 | ||
| @@ -137,6 +138,7 @@ static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); | |||
| 137 | static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); | 138 | static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); |
| 138 | static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); | 139 | static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); |
| 139 | static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); | 140 | static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); |
| 141 | static DEVICE_BOOL_ATTR(scrub_pages, 0644, xen_scrub_pages); | ||
| 140 | 142 | ||
| 141 | static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr, | 143 | static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr, |
| 142 | char *buf) | 144 | char *buf) |
| @@ -203,6 +205,7 @@ static struct attribute *balloon_attrs[] = { | |||
| 203 | &dev_attr_max_schedule_delay.attr.attr, | 205 | &dev_attr_max_schedule_delay.attr.attr, |
| 204 | &dev_attr_retry_count.attr.attr, | 206 | &dev_attr_retry_count.attr.attr, |
| 205 | &dev_attr_max_retry_count.attr.attr, | 207 | &dev_attr_max_retry_count.attr.attr, |
| 208 | &dev_attr_scrub_pages.attr.attr, | ||
| 206 | NULL | 209 | NULL |
| 207 | }; | 210 | }; |
| 208 | 211 | ||
diff --git a/include/xen/mem-reservation.h b/include/xen/mem-reservation.h index 80b52b4945e9..a2ab516fcd2c 100644 --- a/include/xen/mem-reservation.h +++ b/include/xen/mem-reservation.h | |||
| @@ -17,11 +17,12 @@ | |||
| 17 | 17 | ||
| 18 | #include <xen/page.h> | 18 | #include <xen/page.h> |
| 19 | 19 | ||
| 20 | extern bool xen_scrub_pages; | ||
| 21 | |||
| 20 | static inline void xenmem_reservation_scrub_page(struct page *page) | 22 | static inline void xenmem_reservation_scrub_page(struct page *page) |
| 21 | { | 23 | { |
| 22 | #ifdef CONFIG_XEN_SCRUB_PAGES | 24 | if (xen_scrub_pages) |
| 23 | clear_highpage(page); | 25 | clear_highpage(page); |
| 24 | #endif | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | #ifdef CONFIG_XEN_HAVE_PVMMU | 28 | #ifdef CONFIG_XEN_HAVE_PVMMU |
