All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone
@ 2012-12-13 15:48 Olaf Hering
  2012-12-13 15:48 ` [PATCH 2/5] fixed strncat size argument on ppc64 Olaf Hering
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Olaf Hering @ 2012-12-13 15:48 UTC (permalink / raw)
  To: kexec; +Cc: Olaf Hering

Port xen-unstable changeset 24344:72f4e4cb7440 to kexec-tools:

  Pushing stuff onto the stack on x86-64 when we do not specify
  -mno-red-zone is unsafe. Since the complicated asm is due to register
  pressure on i386, we simply implement an all-new simpler alternative
  for x86-64.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 kexec/crashdump-xen.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c
index 9dfabf8..d8bd0f4 100644
--- a/kexec/crashdump-xen.c
+++ b/kexec/crashdump-xen.c
@@ -41,18 +41,21 @@ void xen_sigill_handler(int sig)
 
 static void xen_cpuid(uint32_t idx, uint32_t *regs, int pv_context)
 {
-	asm volatile (
 #ifdef __i386__
-#define R(x) "%%e"#x"x"
+    /* Use the stack to avoid reg constraint failures with some gcc flags */
+    asm volatile (
+        "push %%eax; push %%ebx; push %%ecx; push %%edx\n\t"
+        "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid\n\t"
+        "mov %%eax,(%2); mov %%ebx,4(%2)\n\t"
+        "mov %%ecx,8(%2); mov %%edx,12(%2)\n\t"
+        "pop %%edx; pop %%ecx; pop %%ebx; pop %%eax\n\t"
+        : : "a" (idx), "c" (pv_context), "S" (regs) : "memory" );
 #else
-#define R(x) "%%r"#x"x"
+    asm volatile (
+        "test %5,%5 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid\n\t"
+        : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
+        : "0" (idx), "1" (pv_context), "2" (0) );
 #endif
-	"push "R(a)"; push "R(b)"; push "R(c)"; push "R(d)"\n\t"
-	"test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ; 1: cpuid\n\t"
-	"mov %%eax,(%2); mov %%ebx,4(%2)\n\t"
-	"mov %%ecx,8(%2); mov %%edx,12(%2)\n\t"
-	"pop "R(d)"; pop "R(c)"; pop "R(b)"; pop "R(a)"\n\t"
-	: : "a" (idx), "c" (pv_context), "S" (regs) : "memory" );
 }
 
 static int check_for_xen(int pv_context)
-- 
1.8.0.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] fixed strncat size argument on ppc64
  2012-12-13 15:48 [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Olaf Hering
@ 2012-12-13 15:48 ` Olaf Hering
  2012-12-13 15:48 ` [PATCH 3/5] fix message and indenting in putnode in ppc64 Olaf Hering
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2012-12-13 15:48 UTC (permalink / raw)
  To: kexec; +Cc: Olaf Hering

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 kexec/arch/ppc64/fs2dt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kexec/arch/ppc64/fs2dt.c b/kexec/arch/ppc64/fs2dt.c
index d2b6b18..f02540d 100644
--- a/kexec/arch/ppc64/fs2dt.c
+++ b/kexec/arch/ppc64/fs2dt.c
@@ -499,7 +499,7 @@ static void putnode(void)
 
 	basename = strrchr(pathname,'/');
 
-	strcat(pathname, "/");
+	strncat(pathname, "/", MAXPATH - strlen(pathname) - 1);
 	dn = pathname + strlen(pathname);
 
 	putprops(dn, namelist, numlist);
@@ -560,7 +560,7 @@ static void putnode(void)
 			char *old_param;
 
 			strcpy(filename, pathname);
-			strcat(filename, "bootargs");
+			strncat(filename, "bootargs", MAXPATH - strlen(filename) - 1);
 			fp = fopen(filename, "r");
 			if (fp) {
 				if (getline(&last_cmdline, &cmd_len, fp) == -1)
@@ -599,7 +599,7 @@ static void putnode(void)
 		 * pseries/hvcterminal is supported.
 		 */
 		strcpy(filename, pathname);
-		strncat(filename, "linux,stdout-path", MAXPATH);
+		strncat(filename, "linux,stdout-path", MAXPATH - strlen(filename) - 1);
 		fd = open(filename, O_RDONLY);
 		if (fd == -1) {
 			printf("Unable to find %s, printing from purgatory is diabled\n",
@@ -623,8 +623,8 @@ static void putnode(void)
 		read(fd, buff, statbuf.st_size);
 		close(fd);
 		strncpy(filename, "/proc/device-tree/", MAXPATH);
-		strncat(filename, buff, MAXPATH);
-		strncat(filename, "/compatible", MAXPATH);
+		strncat(filename, buff, MAXPATH - strlen(filename) - 1);
+		strncat(filename, "/compatible", MAXPATH - strlen(filename) - 1);
 		fd = open(filename, O_RDONLY);
 		if (fd == -1) {
 			printf("Unable to find %s printing from purgatory is diabled\n",
-- 
1.8.0.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] fix message and indenting in putnode in ppc64
  2012-12-13 15:48 [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Olaf Hering
  2012-12-13 15:48 ` [PATCH 2/5] fixed strncat size argument on ppc64 Olaf Hering
@ 2012-12-13 15:48 ` Olaf Hering
  2012-12-13 15:48 ` [PATCH 4/5] fix comment typo in do_bzImage_load on x86 Olaf Hering
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2012-12-13 15:48 UTC (permalink / raw)
  To: kexec; +Cc: Olaf Hering

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 kexec/arch/ppc64/fs2dt.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/kexec/arch/ppc64/fs2dt.c b/kexec/arch/ppc64/fs2dt.c
index f02540d..9750c34 100644
--- a/kexec/arch/ppc64/fs2dt.c
+++ b/kexec/arch/ppc64/fs2dt.c
@@ -602,13 +602,11 @@ static void putnode(void)
 		strncat(filename, "linux,stdout-path", MAXPATH - strlen(filename) - 1);
 		fd = open(filename, O_RDONLY);
 		if (fd == -1) {
-			printf("Unable to find %s, printing from purgatory is diabled\n",
-														filename);
+			printf("Unable to find %s, printing from purgatory is disabled\n", filename);
 			goto no_debug;
 		}
 		if (fstat(fd, &statbuf)) {
-			printf("Unable to stat %s, printing from purgatory is diabled\n",
-														filename);
+			printf("Unable to stat %s, printing from purgatory is disabled\n", filename);
 			close(fd);
 			goto no_debug;
 
@@ -627,13 +625,11 @@ static void putnode(void)
 		strncat(filename, "/compatible", MAXPATH - strlen(filename) - 1);
 		fd = open(filename, O_RDONLY);
 		if (fd == -1) {
-			printf("Unable to find %s printing from purgatory is diabled\n",
-														filename);
+			printf("Unable to find %s printing from purgatory is disabled\n", filename);
 			goto no_debug;
 		}
 		if (fstat(fd, &statbuf)) {
-			printf("Unable to stat %s printing from purgatory is diabled\n",
-														filename);
+			printf("Unable to stat %s printing from purgatory is disabled\n", filename);
 			close(fd);
 			goto no_debug;
 		}
-- 
1.8.0.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] fix comment typo in do_bzImage_load on x86
  2012-12-13 15:48 [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Olaf Hering
  2012-12-13 15:48 ` [PATCH 2/5] fixed strncat size argument on ppc64 Olaf Hering
  2012-12-13 15:48 ` [PATCH 3/5] fix message and indenting in putnode in ppc64 Olaf Hering
@ 2012-12-13 15:48 ` Olaf Hering
  2012-12-13 15:48 ` [PATCH 5/5] fix comment typo in locate_hole Olaf Hering
  2012-12-14 13:31 ` [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Simon Horman
  4 siblings, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2012-12-13 15:48 UTC (permalink / raw)
  To: kexec; +Cc: Olaf Hering

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 kexec/arch/i386/kexec-bzImage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 6998587..fd214a3 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -194,7 +194,7 @@ int do_bzImage_load(struct kexec_info *info,
 	}
 
 	/* Load the trampoline.  This must load at a higher address
-	 * the the argument/parameter segment or the kernel will stomp
+	 * than the argument/parameter segment or the kernel will stomp
 	 * it's gdt.
 	 *
 	 * x86_64 purgatory code has got relocations type R_X86_64_32S
-- 
1.8.0.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] fix comment typo in locate_hole
  2012-12-13 15:48 [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Olaf Hering
                   ` (2 preceding siblings ...)
  2012-12-13 15:48 ` [PATCH 4/5] fix comment typo in do_bzImage_load on x86 Olaf Hering
@ 2012-12-13 15:48 ` Olaf Hering
  2012-12-14 13:31 ` [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Simon Horman
  4 siblings, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2012-12-13 15:48 UTC (permalink / raw)
  To: kexec; +Cc: Olaf Hering

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 kexec/kexec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 8928be0..22229d8 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -202,7 +202,7 @@ unsigned long locate_hole(struct kexec_info *info,
 		die("Invalid hole end argument of 0 specified to locate_hole");
 	}
 
-	/* Set an intial invalid value for the hole base */
+	/* Set an initial invalid value for the hole base */
 	hole_base = ULONG_MAX;
 
 	/* Align everything to at least a page size boundary */
-- 
1.8.0.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone
  2012-12-13 15:48 [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Olaf Hering
                   ` (3 preceding siblings ...)
  2012-12-13 15:48 ` [PATCH 5/5] fix comment typo in locate_hole Olaf Hering
@ 2012-12-14 13:31 ` Simon Horman
  4 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2012-12-14 13:31 UTC (permalink / raw)
  To: Olaf Hering; +Cc: kexec

On Thu, Dec 13, 2012 at 04:48:46PM +0100, Olaf Hering wrote:
> Port xen-unstable changeset 24344:72f4e4cb7440 to kexec-tools:
> 
>   Pushing stuff onto the stack on x86-64 when we do not specify
>   -mno-red-zone is unsafe. Since the complicated asm is due to register
>   pressure on i386, we simply implement an all-new simpler alternative
>   for x86-64.

Thanks, all 5 patches applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-12-14 13:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 15:48 [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Olaf Hering
2012-12-13 15:48 ` [PATCH 2/5] fixed strncat size argument on ppc64 Olaf Hering
2012-12-13 15:48 ` [PATCH 3/5] fix message and indenting in putnode in ppc64 Olaf Hering
2012-12-13 15:48 ` [PATCH 4/5] fix comment typo in do_bzImage_load on x86 Olaf Hering
2012-12-13 15:48 ` [PATCH 5/5] fix comment typo in locate_hole Olaf Hering
2012-12-14 13:31 ` [PATCH 1/5] Fix xen_cpuid() inline asm to not clobber stack's red zone Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.