Skip to content

Commit

Permalink
Merge tag 'for-linus-4.7b-rc6-tag' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/xen/tip

Pull xen bug fixes from David Vrabel:

 - Fix two bugs in the handling of xenbus transactions.

 - Make the xen acpi driver compatible with Xen 4.7.

* tag 'for-linus-4.7b-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen/acpi: allow xen-acpi-processor driver to load on Xen 4.7
  xenbus: simplify xenbus_dev_request_and_reply()
  xenbus: don't bail early from xenbus_dev_request_and_reply()
  xenbus: don't BUG() on user mode induced condition
  • Loading branch information
Linus Torvalds committed Jul 8, 2016
2 parents 267ba96 + 6f2d9d9 commit cfae7e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 45 deletions.
35 changes: 3 additions & 32 deletions drivers/xen/xen-acpi-processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,36 +423,7 @@ static int check_acpi_ids(struct acpi_processor *pr_backup)

return 0;
}
static int __init check_prereq(void)
{
struct cpuinfo_x86 *c = &cpu_data(0);

if (!xen_initial_domain())
return -ENODEV;

if (!acpi_gbl_FADT.smi_command)
return -ENODEV;

if (c->x86_vendor == X86_VENDOR_INTEL) {
if (!cpu_has(c, X86_FEATURE_EST))
return -ENODEV;

return 0;
}
if (c->x86_vendor == X86_VENDOR_AMD) {
/* Copied from powernow-k8.h, can't include ../cpufreq/powernow
* as we get compile warnings for the static functions.
*/
#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007
#define USE_HW_PSTATE 0x00000080
u32 eax, ebx, ecx, edx;
cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);
if ((edx & USE_HW_PSTATE) != USE_HW_PSTATE)
return -ENODEV;
return 0;
}
return -ENODEV;
}
/* acpi_perf_data is a pointer to percpu data. */
static struct acpi_processor_performance __percpu *acpi_perf_data;

Expand Down Expand Up @@ -509,10 +480,10 @@ struct notifier_block xen_acpi_processor_resume_nb = {
static int __init xen_acpi_processor_init(void)
{
unsigned int i;
int rc = check_prereq();
int rc;

if (rc)
return rc;
if (!xen_initial_domain())
return -ENODEV;

nr_acpi_bits = get_max_acpi_id() + 1;
acpi_ids_done = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL);
Expand Down
14 changes: 8 additions & 6 deletions drivers/xen/xenbus/xenbus_dev_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,18 @@ static int xenbus_write_transaction(unsigned msg_type,
rc = -ENOMEM;
goto out;
}
} else {
list_for_each_entry(trans, &u->transactions, list)
if (trans->handle.id == u->u.msg.tx_id)
break;
if (&trans->list == &u->transactions)
return -ESRCH;
}

reply = xenbus_dev_request_and_reply(&u->u.msg);
if (IS_ERR(reply)) {
kfree(trans);
if (msg_type == XS_TRANSACTION_START)
kfree(trans);
rc = PTR_ERR(reply);
goto out;
}
Expand All @@ -333,12 +340,7 @@ static int xenbus_write_transaction(unsigned msg_type,
list_add(&trans->list, &u->transactions);
}
} else if (u->u.msg.type == XS_TRANSACTION_END) {
list_for_each_entry(trans, &u->transactions, list)
if (trans->handle.id == u->u.msg.tx_id)
break;
BUG_ON(&trans->list == &u->transactions);
list_del(&trans->list);

kfree(trans);
}

Expand Down
10 changes: 3 additions & 7 deletions drivers/xen/xenbus/xenbus_xs.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ static void transaction_resume(void)
void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
{
void *ret;
struct xsd_sockmsg req_msg = *msg;
enum xsd_sockmsg_type type = msg->type;
int err;

if (req_msg.type == XS_TRANSACTION_START)
if (type == XS_TRANSACTION_START)
transaction_start();

mutex_lock(&xs_state.request_mutex);
Expand All @@ -249,12 +249,8 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)

mutex_unlock(&xs_state.request_mutex);

if (IS_ERR(ret))
return ret;

if ((msg->type == XS_TRANSACTION_END) ||
((req_msg.type == XS_TRANSACTION_START) &&
(msg->type == XS_ERROR)))
((type == XS_TRANSACTION_START) && (msg->type == XS_ERROR)))
transaction_end();

return ret;
Expand Down

0 comments on commit cfae7e3

Please sign in to comment.