From: "H. Peter Anvin" <hpa@zytor.com>
To: "Wang, Shane" <shane.wang@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>,
"Cihula, Joseph" <joseph.cihula@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"arjan@linux.intel.com" <arjan@linux.intel.com>,
"andi@firstfloor.org" <andi@firstfloor.org>,
"chrisw@sous-sol.org" <chrisw@sous-sol.org>,
"jmorris@namei.org" <jmorris@namei.org>,
"jbeulich@novell.com" <jbeulich@novell.com>,
"peterm@redhat.com" <peterm@redhat.com>,
"Wei, Gang" <gang.wei@intel.com>
Subject: Re: [PATCH 1/1] intel_txt: to fix build errors of CONFIG_ACPI_SLEEP
Date: Thu, 13 Aug 2009 20:04:18 -0700 [thread overview]
Message-ID: <4A84D432.2040704@zytor.com> (raw)
In-Reply-To: <037F493892196B458CD3E193E8EBAD4F01EAB6464E@pdsmsx502.ccr.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 679 bytes --]
On 08/13/2009 07:06 PM, Wang, Shane wrote:
> I agree with hpa, considering TXT doesnot depends on acpi sleep.
>
> takes effect but tboot->mac_regions[] will never be used without S3.
>
Given that, I would create a function called tboot_setup_suspend() or
something like that and localize the setting of mac_regions as well as
s3_resume_vector there.
Since it looks like s3_resume_vector is simply set up in tboot_sleep()
before we'd call tboot_shutdown(), we can presumably simply do it all in
tboot_shutdown().
Ingo, Shane: how does the attached patch look?
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 2941 bytes --]
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index 1ab8012..a183bef 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -34,6 +34,7 @@
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
#include <asm/fixmap.h>
+#include <asm/proto.h>
#include <asm/setup.h>
#include <asm/tboot.h>
#include <asm/e820.h>
@@ -164,25 +165,51 @@ void tboot_create_trampoline(void)
map_base = PFN_DOWN(tboot->tboot_base);
map_size = PFN_UP(tboot->tboot_size);
if (map_tboot_pages(map_base << PAGE_SHIFT, map_base, map_size))
- panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n", map_base, map_size);
+ panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n",
+ map_base, map_size);
}
-static void set_mac_regions(void)
+#ifdef CONFIG_ACPI_SLEEP
+
+static void add_mac_region(phys_addr_t start, unsigned long size)
{
- tboot->num_mac_regions = 3;
+ struct tboot_mac_region *mr;
+ phys_addr_t end = start + size;
+
+ if (start && size) {
+ mr = &tboot->mac_regions[tboot->num_mac_regions++];
+ mr->start = round_down(start, PAGE_SIZE);
+ mr->size = round_up(end, PAGE_SIZE) - mr->start;
+ }
+}
+
+static int tboot_setup_sleep(void)
+{
+ tboot->num_mac_regions = 0;
+
/* S3 resume code */
- tboot->mac_regions[0].start = PFN_PHYS(PFN_DOWN(acpi_wakeup_address));
- tboot->mac_regions[0].size = PFN_UP(WAKEUP_SIZE) << PAGE_SHIFT;
+ add_mac_region(acpi_wakeup_address, WAKEUP_SIZE);
/* AP trampoline code */
- tboot->mac_regions[1].start =
- PFN_PHYS(PFN_DOWN(virt_to_phys(trampoline_base)));
- tboot->mac_regions[1].size = PFN_UP(TRAMPOLINE_SIZE) << PAGE_SHIFT;
+ add_mac_region(virt_to_phys(trampoline_base), TRAMPOLINE_SIZE);
/* kernel code + data + bss */
- tboot->mac_regions[2].start = PFN_PHYS(PFN_DOWN(virt_to_phys(&_text)));
- tboot->mac_regions[2].size = PFN_PHYS(PFN_UP(virt_to_phys(&_end))) -
- PFN_PHYS(PFN_DOWN(virt_to_phys(&_text)));
+ add_mac_region(virt_to_phys(_text), _end - _text);
+
+ tboot->acpi_sinfo.kernel_s3_resume_vector = acpi_wakeup_address;
+
+ return 0;
}
+#else /* no CONFIG_ACPI_SLEEP */
+
+static int tboot_setup_sleep(void)
+{
+ /* S3 shutdown requested, but S3 not supported by the kernel... */
+ BUG();
+ return -1;
+}
+
+#endif
+
void tboot_shutdown(u32 shutdown_type)
{
void (*shutdown)(void);
@@ -200,7 +227,8 @@ void tboot_shutdown(u32 shutdown_type)
/* if this is S3 then set regions to MAC */
if (shutdown_type == TB_SHUTDOWN_S3)
- set_mac_regions();
+ if (tboot_setup_sleep())
+ return;
tboot->shutdown_type = shutdown_type;
@@ -253,7 +281,6 @@ void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control;
/* we always use the 32b wakeup vector */
tboot->acpi_sinfo.vector_width = 32;
- tboot->acpi_sinfo.kernel_s3_resume_vector = acpi_wakeup_address;
if (sleep_state >= ACPI_S_STATE_COUNT ||
acpi_shutdown_map[sleep_state] == -1) {
next prev parent reply other threads:[~2009-08-14 3:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-01 2:30 [RFC v6][PATCH 0b/4] intel_txt: Intel(R) Trusted Execution Technology support for Linux - Details Joseph Cihula
2009-08-07 7:27 ` Ingo Molnar
2009-08-12 14:53 ` Ingo Molnar
2009-08-12 15:11 ` H. Peter Anvin
2009-08-12 15:42 ` Wang, Shane
2009-08-12 16:28 ` H. Peter Anvin
2009-08-12 16:30 ` Arjan van de Ven
2009-08-12 17:51 ` H. Peter Anvin
2009-08-12 18:20 ` Andi Kleen
2009-08-12 22:37 ` Wang, Shane
2009-08-12 23:07 ` H. Peter Anvin
2009-08-13 3:45 ` Wang, Shane
2009-08-13 6:48 ` Ingo Molnar
2009-08-13 6:19 ` [PATCH 1/1] intel_txt: to fix build errors of CONFIG_ACPI_SLEEP Wang, Shane
2009-08-13 6:46 ` Ingo Molnar
2009-08-13 15:08 ` H. Peter Anvin
2009-08-13 15:46 ` Ingo Molnar
2009-08-13 15:57 ` H. Peter Anvin
2009-08-14 2:06 ` Wang, Shane
2009-08-14 2:54 ` H. Peter Anvin
2009-08-14 3:04 ` H. Peter Anvin [this message]
2009-08-14 8:52 ` Wang, Shane
2009-08-17 8:03 ` [build bug] " Ingo Molnar
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=4A84D432.2040704@zytor.com \
--to=hpa@zytor.com \
--cc=andi@firstfloor.org \
--cc=arjan@linux.intel.com \
--cc=chrisw@sous-sol.org \
--cc=gang.wei@intel.com \
--cc=jbeulich@novell.com \
--cc=jmorris@namei.org \
--cc=joseph.cihula@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterm@redhat.com \
--cc=shane.wang@intel.com \
/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