Skip to content

Commit 67a7a8f

Browse files
committed
Merge tag 'for-linus-4.17-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: "A few fixes of Xen related core code and drivers" * tag 'for-linus-4.17-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/pvh: Indicate XENFEAT_linux_rsdp_unrestricted to Xen xen/acpi: off by one in read_acpi_id() xen/acpi: upload _PSD info for non Dom0 CPUs too x86/xen: Delay get_cpu_cap until stack canary is established xen: xenbus_dev_frontend: Verify body of XS_TRANSACTION_END xen: xenbus: Catch closing of non existent transactions xen: xenbus_dev_frontend: Fix XS_TRANSACTION_END handling
2 parents c5c177c + a5a18ae commit 67a7a8f

File tree

8 files changed

+79
-19
lines changed

8 files changed

+79
-19
lines changed

arch/x86/xen/enlighten_pv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,10 +1259,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
12591259
*/
12601260
__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
12611261

1262-
/* Work out if we support NX */
1263-
get_cpu_cap(&boot_cpu_data);
1264-
x86_configure_nx();
1265-
12661262
/* Get mfn list */
12671263
xen_build_dynamic_phys_to_machine();
12681264

@@ -1272,6 +1268,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
12721268
*/
12731269
xen_setup_gdt(0);
12741270

1271+
/* Work out if we support NX */
1272+
get_cpu_cap(&boot_cpu_data);
1273+
x86_configure_nx();
1274+
12751275
xen_init_irq_ops();
12761276

12771277
/* Let's presume PV guests always boot on vCPU with id 0. */

arch/x86/xen/xen-head.S

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ END(hypercall_page)
8989
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,
9090
.ascii "!writable_page_tables|pae_pgdir_above_4gb")
9191
ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
92-
.long (1 << XENFEAT_writable_page_tables) | (1 << XENFEAT_dom0))
92+
.long (1 << XENFEAT_writable_page_tables) | \
93+
(1 << XENFEAT_dom0) | \
94+
(1 << XENFEAT_linux_rsdp_unrestricted))
9395
ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
9496
ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
9597
ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,

drivers/acpi/processor_perflib.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,16 @@ int acpi_processor_notify_smm(struct module *calling_module)
533533

534534
EXPORT_SYMBOL(acpi_processor_notify_smm);
535535

536-
static int acpi_processor_get_psd(struct acpi_processor *pr)
536+
int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain)
537537
{
538538
int result = 0;
539539
acpi_status status = AE_OK;
540540
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
541541
struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
542542
struct acpi_buffer state = {0, NULL};
543543
union acpi_object *psd = NULL;
544-
struct acpi_psd_package *pdomain;
545544

546-
status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer);
545+
status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer);
547546
if (ACPI_FAILURE(status)) {
548547
return -ENODEV;
549548
}
@@ -561,8 +560,6 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
561560
goto end;
562561
}
563562

564-
pdomain = &(pr->performance->domain_info);
565-
566563
state.length = sizeof(struct acpi_psd_package);
567564
state.pointer = pdomain;
568565

@@ -597,6 +594,7 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
597594
kfree(buffer.pointer);
598595
return result;
599596
}
597+
EXPORT_SYMBOL(acpi_processor_get_psd);
600598

601599
int acpi_processor_preregister_performance(
602600
struct acpi_processor_performance __percpu *performance)
@@ -645,7 +643,8 @@ int acpi_processor_preregister_performance(
645643

646644
pr->performance = per_cpu_ptr(performance, i);
647645
cpumask_set_cpu(i, pr->performance->shared_cpu_map);
648-
if (acpi_processor_get_psd(pr)) {
646+
pdomain = &(pr->performance->domain_info);
647+
if (acpi_processor_get_psd(pr->handle, pdomain)) {
649648
retval = -EINVAL;
650649
continue;
651650
}

drivers/xen/xen-acpi-processor.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ static unsigned long *acpi_ids_done;
5353
static unsigned long *acpi_id_present;
5454
/* And if there is an _CST definition (or a PBLK) for the ACPI IDs */
5555
static unsigned long *acpi_id_cst_present;
56+
/* Which ACPI P-State dependencies for a enumerated processor */
57+
static struct acpi_psd_package *acpi_psd;
5658

5759
static int push_cxx_to_hypervisor(struct acpi_processor *_pr)
5860
{
@@ -362,16 +364,23 @@ read_acpi_id(acpi_handle handle, u32 lvl, void *context, void **rv)
362364
}
363365
/* There are more ACPI Processor objects than in x2APIC or MADT.
364366
* This can happen with incorrect ACPI SSDT declerations. */
365-
if (acpi_id > nr_acpi_bits) {
366-
pr_debug("We only have %u, trying to set %u\n",
367-
nr_acpi_bits, acpi_id);
367+
if (acpi_id >= nr_acpi_bits) {
368+
pr_debug("max acpi id %u, trying to set %u\n",
369+
nr_acpi_bits - 1, acpi_id);
368370
return AE_OK;
369371
}
370372
/* OK, There is a ACPI Processor object */
371373
__set_bit(acpi_id, acpi_id_present);
372374

373375
pr_debug("ACPI CPU%u w/ PBLK:0x%lx\n", acpi_id, (unsigned long)pblk);
374376

377+
/* It has P-state dependencies */
378+
if (!acpi_processor_get_psd(handle, &acpi_psd[acpi_id])) {
379+
pr_debug("ACPI CPU%u w/ PST:coord_type = %llu domain = %llu\n",
380+
acpi_id, acpi_psd[acpi_id].coord_type,
381+
acpi_psd[acpi_id].domain);
382+
}
383+
375384
status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
376385
if (ACPI_FAILURE(status)) {
377386
if (!pblk)
@@ -405,6 +414,14 @@ static int check_acpi_ids(struct acpi_processor *pr_backup)
405414
return -ENOMEM;
406415
}
407416

417+
acpi_psd = kcalloc(nr_acpi_bits, sizeof(struct acpi_psd_package),
418+
GFP_KERNEL);
419+
if (!acpi_psd) {
420+
kfree(acpi_id_present);
421+
kfree(acpi_id_cst_present);
422+
return -ENOMEM;
423+
}
424+
408425
acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
409426
ACPI_UINT32_MAX,
410427
read_acpi_id, NULL, NULL, NULL);
@@ -417,6 +434,12 @@ static int check_acpi_ids(struct acpi_processor *pr_backup)
417434
pr_backup->acpi_id = i;
418435
/* Mask out C-states if there are no _CST or PBLK */
419436
pr_backup->flags.power = test_bit(i, acpi_id_cst_present);
437+
/* num_entries is non-zero if we evaluated _PSD */
438+
if (acpi_psd[i].num_entries) {
439+
memcpy(&pr_backup->performance->domain_info,
440+
&acpi_psd[i],
441+
sizeof(struct acpi_psd_package));
442+
}
420443
(void)upload_pm_data(pr_backup);
421444
}
422445
}
@@ -566,6 +589,7 @@ static void __exit xen_acpi_processor_exit(void)
566589
kfree(acpi_ids_done);
567590
kfree(acpi_id_present);
568591
kfree(acpi_id_cst_present);
592+
kfree(acpi_psd);
569593
for_each_possible_cpu(i)
570594
acpi_processor_unregister_performance(i);
571595

drivers/xen/xenbus/xenbus_dev_frontend.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ void xenbus_dev_queue_reply(struct xb_req_data *req)
365365
if (WARN_ON(rc))
366366
goto out;
367367
}
368-
} else if (req->msg.type == XS_TRANSACTION_END) {
368+
} else if (req->type == XS_TRANSACTION_END) {
369369
trans = xenbus_get_transaction(u, req->msg.tx_id);
370370
if (WARN_ON(!trans))
371371
goto out;
@@ -429,6 +429,10 @@ static int xenbus_write_transaction(unsigned msg_type,
429429
{
430430
int rc;
431431
struct xenbus_transaction_holder *trans = NULL;
432+
struct {
433+
struct xsd_sockmsg hdr;
434+
char body[];
435+
} *msg = (void *)u->u.buffer;
432436

433437
if (msg_type == XS_TRANSACTION_START) {
434438
trans = kzalloc(sizeof(*trans), GFP_KERNEL);
@@ -437,11 +441,15 @@ static int xenbus_write_transaction(unsigned msg_type,
437441
goto out;
438442
}
439443
list_add(&trans->list, &u->transactions);
440-
} else if (u->u.msg.tx_id != 0 &&
441-
!xenbus_get_transaction(u, u->u.msg.tx_id))
444+
} else if (msg->hdr.tx_id != 0 &&
445+
!xenbus_get_transaction(u, msg->hdr.tx_id))
442446
return xenbus_command_reply(u, XS_ERROR, "ENOENT");
447+
else if (msg_type == XS_TRANSACTION_END &&
448+
!(msg->hdr.len == 2 &&
449+
(!strcmp(msg->body, "T") || !strcmp(msg->body, "F"))))
450+
return xenbus_command_reply(u, XS_ERROR, "EINVAL");
443451

444-
rc = xenbus_dev_request_and_reply(&u->u.msg, u);
452+
rc = xenbus_dev_request_and_reply(&msg->hdr, u);
445453
if (rc && trans) {
446454
list_del(&trans->list);
447455
kfree(trans);

drivers/xen/xenbus/xenbus_xs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ void xs_request_exit(struct xb_req_data *req)
140140
spin_lock(&xs_state_lock);
141141
xs_state_users--;
142142
if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) ||
143-
req->type == XS_TRANSACTION_END)
143+
(req->type == XS_TRANSACTION_END &&
144+
!WARN_ON_ONCE(req->msg.type == XS_ERROR &&
145+
!strcmp(req->body, "ENOENT"))))
144146
xs_state_users--;
145147
spin_unlock(&xs_state_lock);
146148

include/acpi/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ int acpi_processor_pstate_control(void);
254254
/* note: this locks both the calling module and the processor module
255255
if a _PPC object exists, rmmod is disallowed then */
256256
int acpi_processor_notify_smm(struct module *calling_module);
257+
int acpi_processor_get_psd(acpi_handle handle,
258+
struct acpi_psd_package *pdomain);
257259

258260
/* parsing the _P* objects. */
259261
extern int acpi_processor_get_performance_info(struct acpi_processor *pr);

include/xen/interface/features.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
/* x86: Does this Xen host support the MMU_PT_UPDATE_PRESERVE_AD hypercall? */
4343
#define XENFEAT_mmu_pt_update_preserve_ad 5
4444

45+
/* x86: Does this Xen host support the MMU_{CLEAR,COPY}_PAGE hypercall? */
46+
#define XENFEAT_highmem_assist 6
47+
4548
/*
4649
* If set, GNTTABOP_map_grant_ref honors flags to be placed into guest kernel
4750
* available pte bits.
@@ -60,6 +63,26 @@
6063
/* operation as Dom0 is supported */
6164
#define XENFEAT_dom0 11
6265

66+
/* Xen also maps grant references at pfn = mfn.
67+
* This feature flag is deprecated and should not be used.
68+
#define XENFEAT_grant_map_identity 12
69+
*/
70+
71+
/* Guest can use XENMEMF_vnode to specify virtual node for memory op. */
72+
#define XENFEAT_memory_op_vnode_supported 13
73+
74+
/* arm: Hypervisor supports ARM SMC calling convention. */
75+
#define XENFEAT_ARM_SMCCC_supported 14
76+
77+
/*
78+
* x86/PVH: If set, ACPI RSDP can be placed at any address. Otherwise RSDP
79+
* must be located in lower 1MB, as required by ACPI Specification for IA-PC
80+
* systems.
81+
* This feature flag is only consulted if XEN_ELFNOTE_GUEST_OS contains
82+
* the "linux" string.
83+
*/
84+
#define XENFEAT_linux_rsdp_unrestricted 15
85+
6386
#define XENFEAT_NR_SUBMAPS 1
6487

6588
#endif /* __XEN_PUBLIC_FEATURES_H__ */

0 commit comments

Comments
 (0)