qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] qemu-system-sparc uses all host cpu while targetsystem is idle
Date: Wed, 20 Sep 2006 20:44:42 +0200	[thread overview]
Message-ID: <20060920184442.GA3541@sparc.aurel32.net> (raw)
In-Reply-To: <BAY104-F18E5F672A9788CDBED770CFF230@phx.gbl>

On Wed, Sep 20, 2006 at 05:48:48PM +0200, Blue Swirl wrote:
> >CPU suspend is not implemented for sparc guests.
> >Unlike most other targets, suspending the CPU is controlled by the system
> >chipset, not by an instruction on the CPU. See slavio_misc.c
> 
> Suspending is disabled, because it crashes qemu. It can be tested by 
> tweaking slavio_misc.c and renaming the device in OpenBIOS from 
> xxxpower-management to power-management. I can't see why it should crash, 
> the implementation is very straightforward. Or maybe halting the CPU should 
> be delayed until the TB is finished executing and halt only from main loop?
> 

Please find below a patch that "works". It is probably wrong as I wrote it
by copying code from other architectures and trying until it works. Well
I am however convinced of two things:
 - "return EXCP_HALTED;" causes the crash. By removing this line qemu
   doesn't crash anymore, but the patch does not work as expected
   (freeze of the target).
 - The interrupt should be cleared, if not the target freeze.

Now the host CPU is not used at 100% when the Sparc target is idle. I am
using it for about one our with a Debian unstable, and I am writing this
mail from this emulated system.

Ah yes, you aslo need to the trivial patch to openbios.

Bye,
Aurelien


Index: hw/slavio_misc.c
===================================================================
RCS file: /sources/qemu/qemu/hw/slavio_misc.c,v
retrieving revision 1.3
diff -u -r1.3 slavio_misc.c
--- hw/slavio_misc.c	5 Dec 2005 20:31:52 -0000	1.3
+++ hw/slavio_misc.c	20 Sep 2006 18:16:29 -0000
@@ -123,7 +123,7 @@
 	break;
     case 0xa000000:
 	MISC_DPRINTF("Write power management %2.2x\n", val & 0xff);
-#if 0
+#if 1
         // XXX almost works
         cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HALT);
 #endif
Index: cpu-exec.c
===================================================================
RCS file: /sources/qemu/qemu/cpu-exec.c,v
retrieving revision 1.84
diff -u -r1.84 cpu-exec.c
--- cpu-exec.c	29 Jul 2006 19:09:31 -0000	1.84
+++ cpu-exec.c	20 Sep 2006 18:16:30 -0000
@@ -548,8 +548,10 @@
 			//do_interrupt(0, 0, 0, 0, 0);
 			env->interrupt_request &= ~CPU_INTERRUPT_TIMER;
 		    } else if (interrupt_request & CPU_INTERRUPT_HALT) {
-                        env1->halted = 1;
-                        return EXCP_HALTED;
+			env->interrupt_request &= ~CPU_INTERRUPT_HALT;
+			env->halted = 1;
+			env->exception_index = EXCP_HLT;
+			cpu_loop_exit();
                     }
 #elif defined(TARGET_ARM)
                     if (interrupt_request & CPU_INTERRUPT_FIQ



-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

      reply	other threads:[~2006-09-20 18:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-20  9:32 [Qemu-devel] qemu-system-sparc uses all host cpu while target system is idle Aurelien Jarno
2006-09-20 12:27 ` WaxDragon
2006-09-20 13:45 ` Paul Brook
2006-09-20 15:48   ` [Qemu-devel] qemu-system-sparc uses all host cpu while targetsystem " Blue Swirl
2006-09-20 18:44     ` Aurelien Jarno [this message]

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=20060920184442.GA3541@sparc.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).