linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] [patch 04/11] uml: refuse to run without skas if no tt mode in
@ 2005-01-13 21:00 blaisorblade_spam
  2005-01-14 19:24 ` [uml-devel] " Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: blaisorblade_spam @ 2005-01-13 21:00 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, jdike, user-mode-linux-devel, blaisorblade_spam


From: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>

Return an early error message when no TT support is compiled in and no SKAS
support is detected.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---

 linux-2.6.11-paolo/arch/um/kernel/process.c |   35 ++++++++++++++++++++--------
 linux-2.6.11-paolo/arch/um/kernel/um_arch.c |   10 +++++++-
 2 files changed, 35 insertions(+), 10 deletions(-)

diff -puN arch/um/kernel/um_arch.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in arch/um/kernel/um_arch.c
--- linux-2.6.11/arch/um/kernel/um_arch.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in	2005-01-13 21:25:17.601847632 +0100
+++ linux-2.6.11-paolo/arch/um/kernel/um_arch.c	2005-01-13 21:25:17.605847024 +0100
@@ -198,7 +198,7 @@ __uml_setup("ncpus=", uml_ncpus_setup,
 );
 #endif
 
-int force_tt = 0;
+static int force_tt = 0;
 
 #if defined(CONFIG_MODE_TT) && defined(CONFIG_MODE_SKAS)
 #define DEFAULT_TT 0
@@ -319,6 +319,14 @@ int linux_main(int argc, char **argv)
 	if(have_root == 0) add_arg(saved_command_line, DEFAULT_COMMAND_LINE);
 
 	mode_tt = force_tt ? 1 : !can_do_skas();
+#ifndef CONFIG_MODE_TT
+	if (mode_tt) {
+		/*Since CONFIG_MODE_TT is #undef'ed, force_tt cannot be 1. So,
+		 * can_do_skas() returned 0, and the message is correct. */
+		printf("Support for TT mode is disabled, and no SKAS support is present on the host.\n");
+		exit(1);
+	}
+#endif
 	uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
 				     &host_task_size, &task_size);
 
diff -puN arch/um/kernel/process.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in arch/um/kernel/process.c
--- linux-2.6.11/arch/um/kernel/process.c~uml-refuse-to-run-without-skas-if-no-tt-mode-in	2005-01-13 21:25:17.602847480 +0100
+++ linux-2.6.11-paolo/arch/um/kernel/process.c	2005-01-13 21:25:17.605847024 +0100
@@ -375,9 +375,9 @@ void forward_pending_sigio(int target)
 		kill(target, SIGIO);
 }
 
-int can_do_skas(void)
-{
 #ifdef UML_CONFIG_MODE_SKAS
+static inline int check_skas3_ptrace_support(void)
+{
 	struct ptrace_faultinfo fi;
 	void *stack;
 	int pid, n, ret = 1;
@@ -386,29 +386,46 @@ int can_do_skas(void)
 	pid = start_ptraced_child(&stack);
 
 	n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
-	if(n < 0){
+	if (n < 0) {
 		if(errno == EIO)
 			printf("not found\n");
-		else printf("No (unexpected errno - %d)\n", errno);
+		else {
+			perror("not found");
+		}
 		ret = 0;
+	} else {
+		printf("found\n");
 	}
-	else printf("found\n");
 
 	init_registers(pid);
 	stop_ptraced_child(pid, stack, 1, 1);
 
+	return(ret);
+}
+
+int can_do_skas(void)
+{
+	int ret = 1;
+
 	printf("Checking for /proc/mm...");
-	if(os_access("/proc/mm", OS_ACC_W_OK) < 0){
+	if (os_access("/proc/mm", OS_ACC_W_OK) < 0) {
 		printf("not found\n");
 		ret = 0;
+		goto out;
+	} else {
+		printf("found\n");
 	}
-	else printf("found\n");
 
-	return(ret);
+	ret = check_skas3_ptrace_support();
+out:
+	return ret;
+}
 #else
+int can_do_skas(void)
+{
 	return(0);
-#endif
 }
+#endif
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
_


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: [patch 04/11] uml: refuse to run without skas if no tt mode in
  2005-01-13 21:00 [uml-devel] [patch 04/11] uml: refuse to run without skas if no tt mode in blaisorblade_spam
@ 2005-01-14 19:24 ` Jeff Dike
  2005-01-14 20:08   ` Blaisorblade
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Dike @ 2005-01-14 19:24 UTC (permalink / raw)
  To: blaisorblade_spam; +Cc: akpm, linux-kernel, user-mode-linux-devel

Is it my imagination, or did you put the definition of can_do_skas under 
#ifdef UML_CONFIG_MODE_SKAS and failed to do the same for the call?

				Jeff



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: [patch 04/11] uml: refuse to run without skas if no tt mode in
  2005-01-14 19:24 ` [uml-devel] " Jeff Dike
@ 2005-01-14 20:08   ` Blaisorblade
  2005-01-15  1:07     ` Jeff Dike
  0 siblings, 1 reply; 4+ messages in thread
From: Blaisorblade @ 2005-01-14 20:08 UTC (permalink / raw)
  To: Jeff Dike; +Cc: blaisorblade_spam, akpm, linux-kernel, user-mode-linux-devel

On Friday 14 January 2005 20:24, Jeff Dike wrote:
> Is it my imagination, or did you put the definition of can_do_skas under
> #ifdef UML_CONFIG_MODE_SKAS and failed to do the same for the call?

Look at the end:

 #else
+int can_do_skas(void)
+{
        return(0);
-#endif
 }
+#endif

This dummy call could be inlined / moved, anyway this is not performance 
critical - it's anyway nicer to have such null defines in headers. I'll clean 
it up.

While checking your statement, I also discovered that here:

int mode_tt = DEFAULT_TT;
(where DEFAULT_TT is a macro depending on CONFIG options, which is always 0 
except if SKAS mode is disabled)

is ignored, because of the subsequent:

        mode_tt = force_tt ? 1 : !can_do_skas();

So we can probably get rid of DEFAULT_TT. I'll do this in the future.
-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: [patch 04/11] uml: refuse to run without skas if no tt mode in
  2005-01-14 20:08   ` Blaisorblade
@ 2005-01-15  1:07     ` Jeff Dike
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2005-01-15  1:07 UTC (permalink / raw)
  To: Blaisorblade; +Cc: akpm, linux-kernel, user-mode-linux-devel

blaisorblade@yahoo.it said:
> Look at the end: 

Oops, missed that.  Sorry.

			Jeff



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

end of thread, other threads:[~2005-01-14 22:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-13 21:00 [uml-devel] [patch 04/11] uml: refuse to run without skas if no tt mode in blaisorblade_spam
2005-01-14 19:24 ` [uml-devel] " Jeff Dike
2005-01-14 20:08   ` Blaisorblade
2005-01-15  1:07     ` Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox