[PATCH] intel_txt: fix the buggy timeout warning logic in tboot

From: Shane Wang
Date: Mon Sep 28 2009 - 22:27:25 EST


This patch based on an original version by H. Peter Anvin fixed the buggy timeout warning logic in tboot.

---
arch/x86/kernel/tboot.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)


Signed-off-by: Shane Wang <shane.wang@xxxxxxxxx>

diff -r 0edd117ada44 arch/x86/kernel/tboot.c
--- a/arch/x86/kernel/tboot.c Wed Sep 23 10:06:56 2009 -0700
+++ b/arch/x86/kernel/tboot.c Mon Sep 28 07:42:18 2009 -0700
@@ -301,16 +301,17 @@ static int tboot_wait_for_aps(int num_ap
unsigned long timeout;

timeout = AP_WAIT_TIMEOUT*HZ;
- while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps &&
- timeout) {
+ while (timeout) {
+ if (atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps)
+ break;
mdelay(1);
timeout--;
}

- if (timeout)
+ if (!timeout)
pr_warning("tboot wait for APs timeout\n");

- return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
+ return !timeout;
}

static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb, This patch based on an original version by H. Peter Anvin fixed the buggy timeout warning logic in tboot.

Signed-off-by: Shane Wang <shane.wang@xxxxxxxxx>

diff -r 0edd117ada44 arch/x86/kernel/tboot.c
--- a/arch/x86/kernel/tboot.c Wed Sep 23 10:06:56 2009 -0700
+++ b/arch/x86/kernel/tboot.c Mon Sep 28 07:42:18 2009 -0700
@@ -301,16 +301,17 @@ static int tboot_wait_for_aps(int num_ap
unsigned long timeout;

timeout = AP_WAIT_TIMEOUT*HZ;
- while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps &&
- timeout) {
+ while (timeout) {
+ if (atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps)
+ break;
mdelay(1);
timeout--;
}

- if (timeout)
+ if (!timeout)
pr_warning("tboot wait for APs timeout\n");

- return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
+ return !timeout;
}

static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,