public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot for konrad@kernel.org" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, konrad@kernel.org, hpa@zytor.com,
	mingo@kernel.org, konrad.wilk@oracle.com, tglx@linutronix.de,
	rjw@sisk.pl, hpa@linux.intel.com
Subject: [tip:x86/paravirt] x86, wakeup, sleep: Use pvops functions for changing GDT entries
Date: Thu, 11 Apr 2013 16:02:48 -0700	[thread overview]
Message-ID: <tip-4d681be3c33dd74efffbe2a8f70634f7128602ec@git.kernel.org> (raw)
In-Reply-To: <1365194544-14648-5-git-send-email-konrad.wilk@oracle.com>

Commit-ID:  4d681be3c33dd74efffbe2a8f70634f7128602ec
Gitweb:     http://git.kernel.org/tip/4d681be3c33dd74efffbe2a8f70634f7128602ec
Author:     konrad@kernel.org <konrad@kernel.org>
AuthorDate: Fri, 5 Apr 2013 16:42:24 -0400
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 11 Apr 2013 15:41:15 -0700

x86, wakeup, sleep: Use pvops functions for changing GDT entries

We check the TSS descriptor before we try to dereference it.
Also we document what the value '9' actually means using the
AMD64 Architecture Programmer's Manual Volume 2, pg 90:
"Hex value 9: Available 64-bit TSS" and pg 91:
"The available 32-bit TSS (09h), which is redefined as the
available 64-bit TSS."

Without this, on Xen, where the GDT is available as R/O (to
protect the hypervisor from the guest modifying it), we end up
with a pagetable fault.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Link: http://lkml.kernel.org/r/1365194544-14648-5-git-send-email-konrad.wilk@oracle.com
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/power/cpu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index 82c39c5..168da84 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -132,7 +132,10 @@ static void fix_processor_context(void)
 {
 	int cpu = smp_processor_id();
 	struct tss_struct *t = &per_cpu(init_tss, cpu);
-
+#ifdef CONFIG_X86_64
+	struct desc_struct *desc = get_cpu_gdt_table(cpu);
+	tss_desc tss;
+#endif
 	set_tss_desc(cpu, t);	/*
 				 * This just modifies memory; should not be
 				 * necessary. But... This is necessary, because
@@ -141,7 +144,9 @@ static void fix_processor_context(void)
 				 */
 
 #ifdef CONFIG_X86_64
-	get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
+	memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
+	tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
+	write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
 
 	syscall_init();				/* This sets MSR_*STAR and related */
 #endif

      reply	other threads:[~2013-04-11 23:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 20:42 [RFC PATCH] axe the store_gdt() pvops call. (v1) Konrad Rzeszutek Wilk
2013-04-05 20:42 ` [PATCH 1/4] x86/gdt/64-bit: store/load GDT for ACPI S3 or hibernate/resume path is not needed Konrad Rzeszutek Wilk
2013-04-11 22:59   ` [tip:x86/paravirt] x86-64, gdt: Store/ load " tip-bot for Konrad Rzeszutek Wilk
2013-04-12 12:02     ` Rafael J. Wysocki
2013-04-30 21:25       ` Konrad Rzeszutek Wilk
2013-04-30 22:38         ` Rafael J. Wysocki
2013-05-01  0:48           ` Konrad Rzeszutek Wilk
2013-04-05 20:42 ` [PATCH 2/4] x86/gdt/i386: store/load GDT for ACPI S3 or hibernation/resume " Konrad Rzeszutek Wilk
2013-04-11 23:00   ` [tip:x86/paravirt] x86-32, gdt: Store/ load " tip-bot for Konrad Rzeszutek Wilk
2013-04-05 20:42 ` [PATCH 3/4] x86/xen/store_gdt: Remove the pvops variant of store_gdt Konrad Rzeszutek Wilk
2013-04-11 23:01   ` [tip:x86/paravirt] x86, xen, gdt: " tip-bot for Konrad Rzeszutek Wilk
2013-04-05 20:42 ` [PATCH 4/4] x86/wakeup/sleep: Use pvops functions for changing GDT entries Konrad Rzeszutek Wilk
2013-04-11 23:02   ` tip-bot for konrad@kernel.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-4d681be3c33dd74efffbe2a8f70634f7128602ec@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=konrad.wilk@oracle.com \
    --cc=konrad@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rjw@sisk.pl \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox