diff options
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/Kconfig | 17 | ||||
-rw-r--r-- | drivers/xen/balloon.c | 23 | ||||
-rw-r--r-- | drivers/xen/events/events_base.c | 18 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/conf_space.c | 2 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/conf_space.h | 2 | ||||
-rw-r--r-- | drivers/xen/xen-pciback/conf_space_header.c | 61 | ||||
-rw-r--r-- | drivers/xen/xen-scsiback.c | 7 |
7 files changed, 105 insertions, 25 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index b812462083fc..94d96809e686 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
@@ -55,6 +55,23 @@ config XEN_BALLOON_MEMORY_HOTPLUG | |||
55 | 55 | ||
56 | In that case step 3 should be omitted. | 56 | In that case step 3 should be omitted. |
57 | 57 | ||
58 | config XEN_BALLOON_MEMORY_HOTPLUG_LIMIT | ||
59 | int "Hotplugged memory limit (in GiB) for a PV guest" | ||
60 | default 512 if X86_64 | ||
61 | default 4 if X86_32 | ||
62 | range 0 64 if X86_32 | ||
63 | depends on XEN_HAVE_PVMMU | ||
64 | depends on XEN_BALLOON_MEMORY_HOTPLUG | ||
65 | help | ||
66 | Maxmium amount of memory (in GiB) that a PV guest can be | ||
67 | expanded to when using memory hotplug. | ||
68 | |||
69 | A PV guest can have more memory than this limit if is | ||
70 | started with a larger maximum. | ||
71 | |||
72 | This value is used to allocate enough space in internal | ||
73 | tables needed for physical memory administration. | ||
74 | |||
58 | config XEN_SCRUB_PAGES | 75 | config XEN_SCRUB_PAGES |
59 | bool "Scrub pages before returning them to system" | 76 | bool "Scrub pages before returning them to system" |
60 | depends on XEN_BALLOON | 77 | depends on XEN_BALLOON |
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 0b52d92cb2e5..fd933695f232 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -229,6 +229,29 @@ static enum bp_state reserve_additional_memory(long credit) | |||
229 | balloon_hotplug = round_up(balloon_hotplug, PAGES_PER_SECTION); | 229 | balloon_hotplug = round_up(balloon_hotplug, PAGES_PER_SECTION); |
230 | nid = memory_add_physaddr_to_nid(hotplug_start_paddr); | 230 | nid = memory_add_physaddr_to_nid(hotplug_start_paddr); |
231 | 231 | ||
232 | #ifdef CONFIG_XEN_HAVE_PVMMU | ||
233 | /* | ||
234 | * add_memory() will build page tables for the new memory so | ||
235 | * the p2m must contain invalid entries so the correct | ||
236 | * non-present PTEs will be written. | ||
237 | * | ||
238 | * If a failure occurs, the original (identity) p2m entries | ||
239 | * are not restored since this region is now known not to | ||
240 | * conflict with any devices. | ||
241 | */ | ||
242 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { | ||
243 | unsigned long pfn, i; | ||
244 | |||
245 | pfn = PFN_DOWN(hotplug_start_paddr); | ||
246 | for (i = 0; i < balloon_hotplug; i++) { | ||
247 | if (!set_phys_to_machine(pfn + i, INVALID_P2M_ENTRY)) { | ||
248 | pr_warn("set_phys_to_machine() failed, no memory added\n"); | ||
249 | return BP_ECANCELED; | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | #endif | ||
254 | |||
232 | rc = add_memory(nid, hotplug_start_paddr, balloon_hotplug << PAGE_SHIFT); | 255 | rc = add_memory(nid, hotplug_start_paddr, balloon_hotplug << PAGE_SHIFT); |
233 | 256 | ||
234 | if (rc) { | 257 | if (rc) { |
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index b4bca2d4a7e5..70fba973a107 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c | |||
@@ -526,20 +526,26 @@ static unsigned int __startup_pirq(unsigned int irq) | |||
526 | pirq_query_unmask(irq); | 526 | pirq_query_unmask(irq); |
527 | 527 | ||
528 | rc = set_evtchn_to_irq(evtchn, irq); | 528 | rc = set_evtchn_to_irq(evtchn, irq); |
529 | if (rc != 0) { | 529 | if (rc) |
530 | pr_err("irq%d: Failed to set port to irq mapping (%d)\n", | 530 | goto err; |
531 | irq, rc); | 531 | |
532 | xen_evtchn_close(evtchn); | ||
533 | return 0; | ||
534 | } | ||
535 | bind_evtchn_to_cpu(evtchn, 0); | 532 | bind_evtchn_to_cpu(evtchn, 0); |
536 | info->evtchn = evtchn; | 533 | info->evtchn = evtchn; |
537 | 534 | ||
535 | rc = xen_evtchn_port_setup(info); | ||
536 | if (rc) | ||
537 | goto err; | ||
538 | |||
538 | out: | 539 | out: |
539 | unmask_evtchn(evtchn); | 540 | unmask_evtchn(evtchn); |
540 | eoi_pirq(irq_get_irq_data(irq)); | 541 | eoi_pirq(irq_get_irq_data(irq)); |
541 | 542 | ||
542 | return 0; | 543 | return 0; |
544 | |||
545 | err: | ||
546 | pr_err("irq%d: Failed to set port to irq mapping (%d)\n", irq, rc); | ||
547 | xen_evtchn_close(evtchn); | ||
548 | return 0; | ||
543 | } | 549 | } |
544 | 550 | ||
545 | static unsigned int startup_pirq(struct irq_data *data) | 551 | static unsigned int startup_pirq(struct irq_data *data) |
diff --git a/drivers/xen/xen-pciback/conf_space.c b/drivers/xen/xen-pciback/conf_space.c index 46ae0f9f02ad..75fe3d466515 100644 --- a/drivers/xen/xen-pciback/conf_space.c +++ b/drivers/xen/xen-pciback/conf_space.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include "conf_space.h" | 16 | #include "conf_space.h" |
17 | #include "conf_space_quirks.h" | 17 | #include "conf_space_quirks.h" |
18 | 18 | ||
19 | static bool permissive; | 19 | bool permissive; |
20 | module_param(permissive, bool, 0644); | 20 | module_param(permissive, bool, 0644); |
21 | 21 | ||
22 | /* This is where xen_pcibk_read_config_byte, xen_pcibk_read_config_word, | 22 | /* This is where xen_pcibk_read_config_byte, xen_pcibk_read_config_word, |
diff --git a/drivers/xen/xen-pciback/conf_space.h b/drivers/xen/xen-pciback/conf_space.h index e56c934ad137..2e1d73d1d5d0 100644 --- a/drivers/xen/xen-pciback/conf_space.h +++ b/drivers/xen/xen-pciback/conf_space.h | |||
@@ -64,6 +64,8 @@ struct config_field_entry { | |||
64 | void *data; | 64 | void *data; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | extern bool permissive; | ||
68 | |||
67 | #define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset) | 69 | #define OFFSET(cfg_entry) ((cfg_entry)->base_offset+(cfg_entry)->field->offset) |
68 | 70 | ||
69 | /* Add fields to a device - the add_fields macro expects to get a pointer to | 71 | /* Add fields to a device - the add_fields macro expects to get a pointer to |
diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c index c5ee82587e8c..2d7369391472 100644 --- a/drivers/xen/xen-pciback/conf_space_header.c +++ b/drivers/xen/xen-pciback/conf_space_header.c | |||
@@ -11,6 +11,10 @@ | |||
11 | #include "pciback.h" | 11 | #include "pciback.h" |
12 | #include "conf_space.h" | 12 | #include "conf_space.h" |
13 | 13 | ||
14 | struct pci_cmd_info { | ||
15 | u16 val; | ||
16 | }; | ||
17 | |||
14 | struct pci_bar_info { | 18 | struct pci_bar_info { |
15 | u32 val; | 19 | u32 val; |
16 | u32 len_val; | 20 | u32 len_val; |
@@ -20,22 +24,36 @@ struct pci_bar_info { | |||
20 | #define is_enable_cmd(value) ((value)&(PCI_COMMAND_MEMORY|PCI_COMMAND_IO)) | 24 | #define is_enable_cmd(value) ((value)&(PCI_COMMAND_MEMORY|PCI_COMMAND_IO)) |
21 | #define is_master_cmd(value) ((value)&PCI_COMMAND_MASTER) | 25 | #define is_master_cmd(value) ((value)&PCI_COMMAND_MASTER) |
22 | 26 | ||
23 | static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data) | 27 | /* Bits guests are allowed to control in permissive mode. */ |
28 | #define PCI_COMMAND_GUEST (PCI_COMMAND_MASTER|PCI_COMMAND_SPECIAL| \ | ||
29 | PCI_COMMAND_INVALIDATE|PCI_COMMAND_VGA_PALETTE| \ | ||
30 | PCI_COMMAND_WAIT|PCI_COMMAND_FAST_BACK) | ||
31 | |||
32 | static void *command_init(struct pci_dev *dev, int offset) | ||
24 | { | 33 | { |
25 | int i; | 34 | struct pci_cmd_info *cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); |
26 | int ret; | 35 | int err; |
27 | 36 | ||
28 | ret = xen_pcibk_read_config_word(dev, offset, value, data); | 37 | if (!cmd) |
29 | if (!pci_is_enabled(dev)) | 38 | return ERR_PTR(-ENOMEM); |
30 | return ret; | 39 | |
31 | 40 | err = pci_read_config_word(dev, PCI_COMMAND, &cmd->val); | |
32 | for (i = 0; i < PCI_ROM_RESOURCE; i++) { | 41 | if (err) { |
33 | if (dev->resource[i].flags & IORESOURCE_IO) | 42 | kfree(cmd); |
34 | *value |= PCI_COMMAND_IO; | 43 | return ERR_PTR(err); |
35 | if (dev->resource[i].flags & IORESOURCE_MEM) | ||
36 | *value |= PCI_COMMAND_MEMORY; | ||
37 | } | 44 | } |
38 | 45 | ||
46 | return cmd; | ||
47 | } | ||
48 | |||
49 | static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data) | ||
50 | { | ||
51 | int ret = pci_read_config_word(dev, offset, value); | ||
52 | const struct pci_cmd_info *cmd = data; | ||
53 | |||
54 | *value &= PCI_COMMAND_GUEST; | ||
55 | *value |= cmd->val & ~PCI_COMMAND_GUEST; | ||
56 | |||
39 | return ret; | 57 | return ret; |
40 | } | 58 | } |
41 | 59 | ||
@@ -43,6 +61,8 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data) | |||
43 | { | 61 | { |
44 | struct xen_pcibk_dev_data *dev_data; | 62 | struct xen_pcibk_dev_data *dev_data; |
45 | int err; | 63 | int err; |
64 | u16 val; | ||
65 | struct pci_cmd_info *cmd = data; | ||
46 | 66 | ||
47 | dev_data = pci_get_drvdata(dev); | 67 | dev_data = pci_get_drvdata(dev); |
48 | if (!pci_is_enabled(dev) && is_enable_cmd(value)) { | 68 | if (!pci_is_enabled(dev) && is_enable_cmd(value)) { |
@@ -83,6 +103,19 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data) | |||
83 | } | 103 | } |
84 | } | 104 | } |
85 | 105 | ||
106 | cmd->val = value; | ||
107 | |||
108 | if (!permissive && (!dev_data || !dev_data->permissive)) | ||
109 | return 0; | ||
110 | |||
111 | /* Only allow the guest to control certain bits. */ | ||
112 | err = pci_read_config_word(dev, offset, &val); | ||
113 | if (err || val == value) | ||
114 | return err; | ||
115 | |||
116 | value &= PCI_COMMAND_GUEST; | ||
117 | value |= val & ~PCI_COMMAND_GUEST; | ||
118 | |||
86 | return pci_write_config_word(dev, offset, value); | 119 | return pci_write_config_word(dev, offset, value); |
87 | } | 120 | } |
88 | 121 | ||
@@ -282,6 +315,8 @@ static const struct config_field header_common[] = { | |||
282 | { | 315 | { |
283 | .offset = PCI_COMMAND, | 316 | .offset = PCI_COMMAND, |
284 | .size = 2, | 317 | .size = 2, |
318 | .init = command_init, | ||
319 | .release = bar_release, | ||
285 | .u.w.read = command_read, | 320 | .u.w.read = command_read, |
286 | .u.w.write = command_write, | 321 | .u.w.write = command_write, |
287 | }, | 322 | }, |
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 9faca6a60bb0..42bd55a6c237 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c | |||
@@ -1659,11 +1659,8 @@ static int scsiback_make_nexus(struct scsiback_tpg *tpg, | |||
1659 | name); | 1659 | name); |
1660 | goto out; | 1660 | goto out; |
1661 | } | 1661 | } |
1662 | /* | 1662 | /* Now register the TCM pvscsi virtual I_T Nexus as active. */ |
1663 | * Now register the TCM pvscsi virtual I_T Nexus as active with the | 1663 | transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl, |
1664 | * call to __transport_register_session() | ||
1665 | */ | ||
1666 | __transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl, | ||
1667 | tv_nexus->tvn_se_sess, tv_nexus); | 1664 | tv_nexus->tvn_se_sess, tv_nexus); |
1668 | tpg->tpg_nexus = tv_nexus; | 1665 | tpg->tpg_nexus = tv_nexus; |
1669 | 1666 | ||