Skip to contentSkip to conversation

UML - Define jmpbuf access constants

PATCH In review Jeff Dike 3 participants 8 messages Feb 7, 2006 – Jun 7, 2006 User-mode Linux (UML)

lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 2/8 UML - Define jmpbuf access constants

With newer libcs, the JB_* macros (which we shouldn't be using anyway, probably) go away. This patch defines them if setjmp.h doesn't. It'd be nice to have a real way to do this, as sysrq-t requires a way to get registers from out-of-context threads, which we store in jmpbufs.

arch/um/os-Linux/sys-i386/registers.c +6 -0
Index: linux-2.6.15/arch/um/os-Linux/sys-i386/registers.c
===================================================================
@@ -127,6 +127,12 @@ void get_safe_registers(unsigned long *r
 	memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
 }
 
+#ifndef JB_PC
+#define JB_PC 5
+#define JB_SP 4
+#define JB_BP 3
+#endif
+
 void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
 {
 	struct __jmp_buf_tag *jmpbuf = buffer;
arch/um/os-Linux/sys-x86_64/registers.c +6 -0
Index: linux-2.6.15/arch/um/os-Linux/sys-x86_64/registers.c
===================================================================
@@ -75,6 +75,12 @@ void get_safe_registers(unsigned long *r
 	memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
 }
 
+#ifndef JB_PC
+#define JB_PC 7
+#define JB_RSP 6
+#define JB_RBP 1
+#endif
+
 void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
 {
 	struct __jmp_buf_tag *jmpbuf = buffer;

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#1 lore raw
Quoted 2 lines · Jeff Dike

With newer libcs, the JB_* macros (which we shouldn't be using anyway, probably) go away.

I assume you have your own setjmp implementation and are not using the libc version?

If you don't then there is a problem. There is a good reason why the constants are removed: you couldn't use the values anyway. Your don't have the information to "decrypt" them. If you just used the values and implemented the function yourself, fine.

author
#2 lore raw
Quoted 2 lines · Ulrich Drepper

I assume you have your own setjmp implementation and are not using the libc version?

Nope, that would be the next step if this turned out to be untenable, which I guess it is.

Quoted 3 lines

If you don't then there is a problem. There is a good reason why the constants are removed: you couldn't use the values anyway. Your don't have the information to "decrypt" them.

You're actually encrypting them somehow? How? And why?

Is there a reason there can't be an API for looking at the contents of a jmp_buf?

Jeff

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw
Quoted 2 lines · Jeff Dike

Nope, that would be the next step if this turned out to be untenable, which I guess it is.

You have to do it if you want to keep using the setjmp interface.

Quoted 1 line

You're actually encrypting them somehow? How? And why?

For security reasons.

Quoted 2 lines

Is there a reason there can't be an API for looking at the contents of a jmp_buf?

It's not needed. There is no reason to look at the content of the struct except if you do something which isn't guaranteed by the spec. I'll definitely not add such an interface. If you need this functionality, implement it yourself. setjmp is most likely overkill anyway.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

author
#4 lore raw
Quoted 3 lines · Ulrich Drepper

If you need this
functionality, implement it yourself. setjmp is most likely overkill anyway.

OK, I'll roll my own version.

Jeff

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#5 lore raw
Quoted 6 lines · Jeff Dike
Quoted 3 lines · Ulrich Drepper

If you need this
functionality, implement it yourself. setjmp is most likely overkill anyway.

OK, I'll roll my own version.

What about #ifdef'ing out the offending code #ifndef one of these constants (they'll be defined or not altogether). As expectable, this wasn't yet implemented - let's give the right priority to things.
(I've just met this on my SuSE, btw, which prompted me to write this email).

Signature · 5 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 
author
#6 lore raw
Quoted 4 lines · Blaisorblade

What about #ifdef'ing out the offending code #ifndef one of these constants (they'll be defined or not altogether). As expectable, this wasn't yet implemented - let's give the right priority to things.
(I've just met this on my SuSE, btw, which prompted me to write this email).

I think hpa just came to our rescue. There's a setjmp/longjmp implementation in klibc. If we pull that in and use it, we don't need our own copy.

Jeff

#7 lore raw
Quoted 10 lines · Jeff Dike
Quoted 5 lines · Blaisorblade

What about #ifdef'ing out the offending code #ifndef one of these constants (they'll be defined or not altogether). As expectable, this wasn't yet implemented - let's give the right priority to things. (I've just met this on my SuSE, btw, which prompted me to write this email).

I think hpa just came to our rescue. There's a setjmp/longjmp implementation in klibc. If we pull that in and use it, we don't need our own copy.

Ok - but we can merge something before 2.6.17, and we should. Any of them. Guess which one...

Not merging hacks is sometimes ok, and guarantees better code. But we're exceeding in this :-)

Signature · 5 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com