Re: [RFC] Porting KVM to QEMU CVS

Anthony Liguori
2006-12-21T04:04:19Z

[-- Attachment #1: Type: text/plain, Size: 2125 bytes --]

Avi Kivity wrote:
> Anthony Liguori wrote:
>> Any thoughts?
>
> SMM continues the tradition of making each x86 generation hackier than
> before.
>
> What happens (probably) is that the virtual hardware unmaps the vga
> memory when SMM is entered, and uses the physical memory at these
> addresses (which is not normally accessible) to store the SMI handler code.

Doh! SMM uses the VGA memory doesn't it. Now it all makes sense :-)

If I disable SMM in the Bochs BIOS, the patch works quite happily with
the latest CVS. I've attached the patch for reference.

> The way to fix this (again, probably) is to:
>
> 1. Revert the 0-640K/1MB-end-of-memory slot thing and create just one
> memory slot for all physical RAM.

We lose the VGA optimization here right?

> 2. Add hacks in the memory slot code to not return a memory slot if the
> physical address is in the forbidden range.

I'm not sure I understand what you mean by this. I guess I have to
spend some time and understand how the whole memory slot thing works.

> 3. Add another hack to disable the first hack when SMM is entered and
> re-enabled it when SMM is exited (e.g. some ioctl).

I'll have to read a little more into SMM. It can be entered at any
moment right? I seem to recall that either the VT or SVM spec has
special handling for SMIs?

Another option to consider would simply be to have the BIOS detect
whether or not the emulated hardware supports SMM dynamically (right
now, it's a compile time switch). This would let us turn it off in QEMU
when KVM is enabled.

>
>> Is anyone else working on this?
>
> I intended to merge qemu once a release is made. However, if you get
> this working and it is stable, it may make sense to merge sooner as I
> very much like qemu cvs.

I would rather just submit this patch (with the BIOS hack) to QEMU and
try and get it picked up in CVS. There are some regressions at the
moment in CVS so it may be nice for users to have an 0.8.2 based version
available. What do you think?

Would be nice to have KVM support in QEMU CVS by the time 2.6.20 rolls out.

Regards,

Anthony Liguori

[-- Attachment #2: rombios-smm.diff --]
[-- Type: text/x-patch, Size: 1962 bytes --]

? _rombios_.c
? _rombiosl_.c
? biossums
? rombios.s
? rombios.sym
? rombios.txt
? rombios16.bin
? rombios32.bin
? rombios32.out
? rombiosl.s
? rombiosl.sym
? rombiosl.txt
Index: BIOS-bochs-latest
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/BIOS-bochs-latest,v
retrieving revision 1.141
diff -u -r1.141 BIOS-bochs-latest
Binary files /tmp/cvsCh2IkN and BIOS-bochs-latest differ
Index: BIOS-bochs-legacy
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/BIOS-bochs-legacy,v
retrieving revision 1.5
diff -u -r1.5 BIOS-bochs-legacy
Binary files /tmp/cvsQC2QUQ and BIOS-bochs-legacy differ
Index: rombios.h
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios.h,v
retrieving revision 1.3
diff -u -r1.3 rombios.h
--- rombios.h 3 Oct 2006 20:27:30 -0000 1.3
+++ rombios.h 21 Dec 2006 04:02:40 -0000
@@ -19,7 +19,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

/* define it to include QEMU specific code */
-//#define BX_QEMU
+#define BX_QEMU

#ifndef LEGACY
# define BX_ROMBIOS32 1
Index: rombios32.c
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios32.c,v
retrieving revision 1.8
diff -u -r1.8 rombios32.c
--- rombios32.c 3 Oct 2006 20:27:30 -0000 1.8
+++ rombios32.c 21 Dec 2006 04:02:41 -0000
@@ -38,7 +38,7 @@
//#define BX_USE_EBDA_TABLES

/* define it if the (emulated) hardware supports SMM mode */
-#define BX_USE_SMM
+//#define BX_USE_SMM

#define cpuid(index, eax, ebx, ecx, edx) \
asm volatile ("cpuid" \
@@ -852,6 +852,11 @@
int ioapic_id, i, len;
int mp_config_table_size;

+#ifdef BX_QEMU
+ if (smp_cpus <= 1)
+ return 1;
+#endif
+
#ifdef BX_USE_EBDA_TABLES
mp_config_table = (uint8_t *)(ram_size - ACPI_DATA_SIZE - MPTABLE_MAX_SIZE);
#else

[-- Attachment #3: Type: text/plain, Size: 347 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org