Commit Graph

324 Commits

Author SHA1 Message Date
Jordan Justen 6cf5778961 OvmfPkg/Sec: Build identity mapped pages in RAM for X64
This is based on MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c.

Previously we would run using page tables built into the
firmware device.

If a flash memory is available, it is unsafe for the page
tables to be stored in memory since the processor may try
to write to the page table data structures.

Additionally, when KVM ROM support is enabled for the
firmware device, then PEI fails to boot when the page
tables are in the firmware device.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14494 6f19259b-4bc3-4df7-8a09-765794883524
2013-07-18 22:51:27 +00:00
Jordan Justen ca270eb727 OvmfPkg: Add IndustryStandard/X64Paging.h
Taken from MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14493 6f19259b-4bc3-4df7-8a09-765794883524
2013-07-18 22:51:16 +00:00
Jordan Justen d52c2868b4 OvmfPkg ResetSystemLib: Fix shutdown via UEFI runtime services
When the PM base address was moved from 0x400 to 0xb000, this
code was missed. This prevented shutdown's via the UEFI system
call from working. (For example, at the EFI shell prompt: reset -s)

We now use gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
which is currently set at 0xb000.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14492 6f19259b-4bc3-4df7-8a09-765794883524
2013-07-18 22:51:10 +00:00
Ruiyu Ni 0086fca024 Fix IA32 build failure.
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14472 6f19259b-4bc3-4df7-8a09-765794883524
2013-07-16 03:06:24 +00:00
Star Zeng c30f1e0974 OvmfPkg EmuVariableFvbRuntimeDxe: Let FaultTolerantWriteDxe to init working block header.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14458 6f19259b-4bc3-4df7-8a09-765794883524
2013-07-03 09:26:49 +00:00
Jordan Justen fd4ba547a1 OvmfPkg: Reduce PcdMaxVariableSize with secure boot to avoid assert
r14252 causes OVMF to crash if SECURE_BOOT_ENABLE is set,
because PcdMaxVariableSize is set to a larger value than
required. In other platforms, 0x2000 seems to be sufficient.

Reported-by: Gary Ching-Pang Lin <glin@suse.com>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14423 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 21:37:44 +00:00
Laszlo Ersek 7a1f59476d OvmfPkg: enable building VirtioNetDxe
Also summarize the resultant NIC driver options in the README file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14421 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:41:13 +00:00
Jordan Justen 8258c4e643 OvmfPkg/VirtioNetDxe: Fix build errors on VS2012 (IA32 & X64)
These changes were needed in addition to the silence.patch
that Laszlo posted on May 28.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14420 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:41:05 +00:00
Laszlo Ersek 9f3acbb5c9 OvmfPkg: VirtioNetDxe: fix some build errors emitted by Visual Studio
These were found with the gcc-4.4 option "-Wconversion" after Jordan
reported the build failure under Visual Studio. The patch was originally
posted to edk2-devel as "silence.patch":

http://thread.gmane.org/gmane.comp.bios.tianocore.devel/2804/focus=2972

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14419 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:59 +00:00
Laszlo Ersek 65575e4f13 OvmfPkg: VirtioNetDxe: complete driver with INF file
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14418 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:53 +00:00
Laszlo Ersek 38f52db9c9 OvmfPkg: VirtioNetDxe: WaitForPacket and EXIT_BOOT_SERVICES event callbacks
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14417 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:47 +00:00
Laszlo Ersek d0e5ff0a0d OvmfPkg: VirtioNetDxe: definitions of unsupported SNP member functions
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14416 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:42 +00:00
Laszlo Ersek 1771d0a1ee OvmfPkg: VirtioNetDxe: emulate Rx filter configuration: SNP.ReceiveFilters
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14415 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:36 +00:00
Laszlo Ersek f8ec2cc52c OvmfPkg: VirtioNetDxe: map multicast IP to MAC: SNP.McastIpToMac
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14414 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:30 +00:00
Laszlo Ersek b6dfc654c8 OvmfPkg: VirtioNetDxe: implement Tx: SNP.Transmit and SNP.GetStatus
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14413 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:24 +00:00
Laszlo Ersek e12fadc3cf OvmfPkg: VirtioNetDxe: SNP.Receive
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14412 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:17 +00:00
Laszlo Ersek 80682e9b2f OvmfPkg: VirtioNetDxe: SNP.Shutdown
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14411 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:11 +00:00
Laszlo Ersek 12384f9b26 OvmfPkg: VirtioNetDxe: add SNP.Initialize and shared dependencies
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14410 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:40:05 +00:00
Laszlo Ersek 395e912e72 OvmfPkg: VirtioNetDxe: Simple Network Protocol members Start and Stop
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14409 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:39:58 +00:00
Laszlo Ersek 16e0ece611 OvmfPkg: VirtioNetDxe: driver binding
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14408 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:39:52 +00:00
Laszlo Ersek bde8a2e0db OvmfPkg: VirtioNetDxe: Component Name Protocol implementation
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14407 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:39:46 +00:00
Laszlo Ersek 193730d128 OvmfPkg: VirtioNetDxe: add entry point
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14406 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:39:40 +00:00
Laszlo Ersek 201cac0d5a OvmfPkg: VirtioNetDxe: declarations and macro definitions
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14405 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:39:32 +00:00
Laszlo Ersek 50d4fa86db OvmfPkg: VirtioNetDxe: add technical notes
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14404 6f19259b-4bc3-4df7-8a09-765794883524
2013-06-14 07:39:25 +00:00
jljusten e678f9db89 OvmfPkg/SerializeVariablesLib: ignore secure variable restore errors
OvmfPkg's file-based NvVar storage is read back as follows at boot (all
paths under OvmfPkg/Library/):

PlatformBdsPolicyBehavior() [PlatformBdsLib/BdsPlatform.c]
  PlatformBdsRestoreNvVarsFromHardDisk()
    VisitAllInstancesOfProtocol
      for each simple file system:
        VisitingFileSystemInstance()
          ConnectNvVarsToFileSystem() [NvVarsFileLib/NvVarsFileLib.c]
            LoadNvVarsFromFs() [NvVarsFileLib/FsAccess.c]
              ReadNvVarsFile()
+-------------> SerializeVariablesSetSerializedVariables() [SerializeVariablesLib/SerializeVariablesLib.c]
|                 SerializeVariablesIterateInstanceVariables()
|   +-------------> IterateVariablesInBuffer()
|   |                 for each loaded / deserialized variable:
| +-|-----------------> IterateVariablesCallbackSetSystemVariable()
| | |                     gRT->SetVariable()
| | |
| | IterateVariablesInBuffer() stops processing variables as soon as the
| | first error is encountered from the callback function.
| |
| | In this case the callback function is
| IterateVariablesCallbackSetSystemVariable(), selected by
SerializeVariablesSetSerializedVariables().

The result is that no NvVar is restored from the file after the first
gRT->SetVariable() failure.

On my system such a failure
- never happens in an OVMF build with secure boot disabled,
- happens *immediately* with SECURE_BOOT_ENABLE, because the first
  variable to restore is "AuthVarKeyDatabase".

"AuthVarKeyDatabase" has the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
attribute set. Since the loop tries to restore it before any keys (PK, KEK
etc) are enrolled, gRT->SetVariable() rejects it with
EFI_SECURITY_VIOLATION. Consequently the NvVar restore loop terminates
immediately, and we never reach non-authenticated variables such as
Boot#### and BootOrder.

Until work on KVM-compatible flash emulation converges between qemu and
OvmfPkg, improve the SECURE_BOOT_ENABLE boot experience by masking
EFI_SECURITY_VIOLATION in the callback:
- authenticated variables continue to be rejected same as before, but
- at least we allow the loop to progress and restore non-authenticated
  variables, for example boot options.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14390 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-28 17:21:37 +00:00
jljusten e7a7e48036 OvmfPkg: QemuBootOrder: recognize Ethernet OFW device paths
Tested with the e1000, ne2k_pci, pcnet, rtl8139, and virtio iPXE UEFI
oprom drivers distributed with qemu-1.5.0-rc1. Also tested with Intel's
e1000 driver.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14367 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-15 18:21:08 +00:00
jljusten 7628b0f5aa OvmfPkg: enable the generic network stack by default
DHCP, PXE, and StdLib socket apps are enabled in OVMF by the sum of:
(a) a UEFI NIC driver,
(b) the generic network stack.

The only choice for (a) used to be the proprietary Intel E1000 driver,
which is cumbersome to obtain and enable.

The iPXE UEFI NIC drivers packaged with qemu-1.5 cover (a) for each NIC
type supported by qemu, and are easy to obtain & configure, even for
earlier qemu versions. Therefore enable (b) per default as well.

This doesn't take up much space; the binaries (b) adds to the firmware
don't seem to need -D FD_SIZE_2MB.

Intel's e1000 driver remains an option, requested by the -D E1000_ENABLE
build flag.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14366 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-15 18:20:39 +00:00
jljusten bf23b44d92 OvmfPkg: describe debug messages in the README file
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14364 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-15 08:09:29 +00:00
jljusten a7615fa875 OvmfPkg: adapt VirtioFlush()'s leading comment to the coding style
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14362 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-15 06:23:22 +00:00
jljusten 11a5fdf437 OvmfPkg: adapt VirtioAppendDesc()'s leading comment to the coding style
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14361 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-15 06:22:50 +00:00
jljusten f2965f4e26 OvmfPkg: adapt VirtioPrepare()'s leading comment to the coding style
Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14360 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-15 06:22:15 +00:00
jljusten 635a3ca2a1 OvmfPkg: VirtioLib: populate the Available Ring correctly
The descriptor table (also known as "queue") consists of descriptors. (The
corresponding type in the code is VRING_DESC.)

An individual descriptor describes a contiguous buffer, to be transferred
uni-directionally between host and guest.

Several descriptors in the descriptor table can be linked into a
descriptor chain, specifying a bi-directional scatter-gather transfer
between host and guest. Such a descriptor chain is also known as "virtio
request".

(The descriptor table can host sereval descriptor chains (in-flight virtio
requests) in parallel, but the OVMF driver supports at most one chain, at
any point in time.)

The first descriptor in any descriptor chain is called "head descriptor".
In order to submit a number of parallel requests (= a set of independent
descriptor chains) from the guest to the host, the guest must put *only*
the head descriptor of each separate chain onto the Available Ring.

VirtioLib currently places the head of its one descriptor chain onto the
Available Ring repeatedly, once for each single (head *or* dependent)
descriptor in said descriptor chain. If the descriptor chain comprises N
descriptors, this error amounts to submitting the same entire chain N
times in parallel.

  Available Ring    Descriptor table
    Ptr to head ----> Desc#0     (head of chain)
    Ptr to head --/   Desc#1     (next in same chain)
    ...          /    ...
    Ptr to head /     Desc#(N-1) (last in same chain)

Anatomy of a single virtio-blk READ request (a descriptor chain with three
descriptors):

  virtio-blk request header, prepared by guest:
    VirtioAppendDesc PhysAddr=3FBC6050 Size=16 Flags=1 Head=1232 Next=1232

  payload to be filled in by host:
    VirtioAppendDesc PhysAddr=3B934C00 Size=32768 Flags=3 Head=1232 Next=1233

  host status, to be filled in by host:
    VirtioAppendDesc PhysAddr=3FBC604F Size=1 Flags=2 Head=1232 Next=1234

Processing on the host side -- the descriptor chain is processed three
times in parallel (its head is available to virtqueue_pop() thrice); the
same chain is submitted/collected separately to/from AIO three times:

  virtio_queue_notify vdev VDEV vq VQ#0

  virtqueue_pop vq VQ#0 elem EL#0 in_num 2 out_num 1
  bdrv_aio_readv bs BDRV sector_num 585792 nb_sectors 64 opaque REQ#0

  virtqueue_pop vq VQ#0 elem EL#1 in_num 2 out_num 1
  bdrv_aio_readv bs BDRV sector_num 585792 nb_sectors 64 opaque REQ#1

  virtqueue_pop vq VQ#0 elem EL#2 in_num 2 out_num 1
  bdrv_aio_readv bs BDRV sector_num 585792 nb_sectors 64 opaque REQ#2

  virtio_blk_rw_complete req REQ#0 ret 0
  virtio_blk_req_complete req REQ#0 status 0

  virtio_blk_rw_complete req REQ#1 ret 0
  virtio_blk_req_complete req REQ#1 status 0

  virtio_blk_rw_complete req REQ#2 ret 0
  virtio_blk_req_complete req REQ#2 status 0

On my Thinkpad T510 laptop with RHEL-6 as host, this probably leads to
simultaneous DMA transfers targeting the same RAM area. Even though the
source of each transfer is identical, the data is corrupted in the
destination buffer -- the CRC32 calculated over the buffer varies, even
though the origin of the transfers is the same, never rewritten LBA.

  SynchronousRequest Lba=585792 BufSiz=32768 ReqIsWrite=0 Crc32=BF68A44D

The problem is invisible on my HP Z400 workstation.

Fix the request submission by:
- building the only one descriptor chain supported by VirtioLib always at
  the beginning of the descriptor table,
- ensuring the head descriptor of this chain is put on the Available Ring
  only once,
- requesting the virtio spec's language to be cleaned up
  <http://lists.linuxfoundation.org/pipermail/virtualization/2013-April/024032.html>.

  Available Ring    Descriptor table
    Ptr to head ----> Desc#0     (head of chain)
                      Desc#1     (next in same chain)
                      ...
                      Desc#(N-1) (last in same chain)

  VirtioAppendDesc PhysAddr=3FBC6040 Size=16 Flags=1 Head=0 Next=0
  VirtioAppendDesc PhysAddr=3B934C00 Size=32768 Flags=3 Head=0 Next=1
  VirtioAppendDesc PhysAddr=3FBC603F Size=1 Flags=2 Head=0 Next=2

    virtio_queue_notify vdev VDEV vq VQ#0

    virtqueue_pop vq VQ#0 elem EL#0 in_num 2 out_num 1
    bdrv_aio_readv bs BDRV sector_num 585792 nb_sectors 64 opaque REQ#0

    virtio_blk_rw_complete req REQ#0 ret 0
    virtio_blk_req_complete req REQ#0 status 0

  SynchronousRequest Lba=585792 BufSiz=32768 ReqIsWrite=0 Crc32=1EEB2B07

(The Crc32 was double-checked with edk2's and Linux's guest IDE driver.)

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14356 6f19259b-4bc3-4df7-8a09-765794883524
2013-05-14 15:57:55 +00:00
jljusten e79095b7b7 OvmfPkg: remove OvmfVideo.rom references
The README is rather extended than trimmed, so that users grepping for the
file name have a pointer.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14243 6f19259b-4bc3-4df7-8a09-765794883524
2013-04-03 18:20:57 +00:00
jljusten fb2ae5fdb5 OvmfPkg: make sure ResetCold() and ResetWarm() never return
Also, add a small delay after the 0xCF9 hard reset request -- on qemu/kvm the
port access is translated to the qemu-internal system reset request by the CPU
thread, and it might progress some more before the IO thread acts upon the
system reset request.

MicroSecondDelay() is implemented by OvmfPkg's own AcpiTimerLib.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14158 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:38:42 +00:00
jljusten cb7b12ee3c OvmfPkg: attempt to trigger cold reset through PIIX3 reset control register
The reset requested via the keyboard controller (port 0x64) is actually a
soft reset, but qemu has supported it since forever (plus qemu has not
distinguished between hard reset and soft reset, although this is changing
now). Therefore leave the current IoWrite() in place for compatibility.

On qemu versions with commit 1ec4ba74 ("PIIX3: reset the VM when the Reset
Control Register's RCPU bit gets set"), use the PIIX3 RCR as first choice.
In the future qemu will act differently on soft vs. hard reset requests,
and we should honor that in ResetCold().

  Writing to ioport 0xCF9 on qemu builds prior to commit 1ec4ba74 should
  have no effect. Access to the PCI host config register went through
  several implementations in qemu. Commit 9f6f0423 ("pci_host: rewrite
  using rwhandler") seems safe, both before and after.

  Commit d0ed8076 ("pci_host: convert conf index and data ports to memory
  API") inadvertently dropped the alignment/size check, causing a boot
  regression on NetBSD. It was fixed about six months later in commit
  cdde6ffc, which is current. Translating that to qemu releases, the bug
  was visible from v1.0 to v1.1.0.

On physical hardware cycling between reset methods is sometimes necessary
<http://mjg59.dreamwidth.org/3561.html>. On qemu the port access should
trap immediately.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14157 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:38:24 +00:00
jljusten 1bccb20cf0 OvmfPkg: report support for the PIIX3 reset register in the FADT
The value to be written corresponds to hard reset, which is what the ACPI
spec prescribes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14156 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:38:05 +00:00
jljusten 304606c0b6 OvmfPkg: upgrade the FADT to ACPI 2.0 without functional changes
This conversion cannot be split very well into smaller patches. Comparing
version 1 and version 2 (modulo the header fields):

> --- EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
> +++ EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE
> @@ -1,14 +1,14 @@
>    EFI_ACPI_DESCRIPTION_HEADER             Header;
>    UINT32                                  FirmwareCtrl;
>    UINT32                                  Dsdt;
> -  UINT8                                   IntModel;
> -  UINT8                                   Reserved1;
> +  UINT8                                   Reserved0;
> +  UINT8                                   PreferredPmProfile;

The INT_MODEL field was present in ACPI 1.0, but eliminated in 2.0.
According to the spec, "platforms should set this field to zero but field
values of one are also allowed to maintain compatibility with ACPI 1.0".
We're setting it to zero.

About Preferred_PM_Profile (taking the place of an 1.0 reserved field),
the specification says:

  This field is set by the OEM to convey the preferred power management
  profile to OSPM. OSPM can use this field to set default power management
  policy parameters during OS installation.

>From <MdePkg/Include/IndustryStandard/Acpi20.h>:

  #define EFI_ACPI_2_0_PM_PROFILE_UNSPECIFIED         0
  #define EFI_ACPI_2_0_PM_PROFILE_DESKTOP             1
  #define EFI_ACPI_2_0_PM_PROFILE_MOBILE              2
  #define EFI_ACPI_2_0_PM_PROFILE_WORKSTATION         3
  #define EFI_ACPI_2_0_PM_PROFILE_ENTERPRISE_SERVER   4
  #define EFI_ACPI_2_0_PM_PROFILE_SOHO_SERVER         5
  #define EFI_ACPI_2_0_PM_PROFILE_APPLIANCE_PC        6

For a virtual machine, "unspecified" is the best choice.

>    UINT16                                  SciInt;
>    UINT32                                  SmiCmd;
>    UINT8                                   AcpiEnable;
>    UINT8                                   AcpiDisable;
>    UINT8                                   S4BiosReq;
> -  UINT8                                   Reserved2;
> +  UINT8                                   PstateCnt;

We've been already treating this field as PSTATE_CNT. No change in value.

>    UINT32                                  Pm1aEvtBlk;
>    UINT32                                  Pm1bEvtBlk;
>    UINT32                                  Pm1aCntBlk;
> @@ -20,11 +20,11 @@
>    UINT8                                   Pm1EvtLen;
>    UINT8                                   Pm1CntLen;
>    UINT8                                   Pm2CntLen;
> -  UINT8                                   PmTmLen;
> +  UINT8                                   PmTmrLen;

(Field renaming artifact.)

>    UINT8                                   Gpe0BlkLen;
>    UINT8                                   Gpe1BlkLen;
>    UINT8                                   Gpe1Base;
> -  UINT8                                   Reserved3;
> +  UINT8                                   CstCnt;

We've been already treating this field as CST_CNT. No change in value.

>    UINT16                                  PLvl2Lat;
>    UINT16                                  PLvl3Lat;
>    UINT16                                  FlushSize;
> @@ -34,7 +34,19 @@
>    UINT8                                   DayAlrm;
>    UINT8                                   MonAlrm;
>    UINT8                                   Century;
> -  UINT8                                   Reserved4;
> -  UINT8                                   Reserved5;
> -  UINT8                                   Reserved6;
> +  UINT16                                  IaPcBootArch;
> +  UINT8                                   Reserved1;

The first two octets are now merged into a 16-bit short; otherwise we've
been treating those as boot architecture flags already (see SVN rev
13615). No change in value.

>    UINT32                                  Flags;

The fixed feature flags are not modified, only the macro names (expanding
to identical values) are updated to ACPI 2.0.

The following fields are all new in ACPI 2.0:

> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  ResetReg;
> +  UINT8                                   ResetValue;

We don't claim support for the reset register yet.

> +  UINT8                                   Reserved2[3];
> +  UINT64                                  XFirmwareCtrl;
> +  UINT64                                  XDsdt;

The 64-bit physical addresses for the FACS and the DSDT are automatically
filled at installation time, see AddTableToList() and DeleteTable() in
"MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c".

> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1aEvtBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1bEvtBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1aCntBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm1bCntBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPm2CntBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XPmTmrBlk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XGpe0Blk;
> +  EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE  XGpe1Blk;

We specify the extended addresses for the required and supported PM1a
Event & Control, PM Timer, and GPE0 Register Blocks, and zero the rest, in
accordance with the ACPI 1.0 fields.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14155 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:37:47 +00:00
jljusten e1fad9b3ba OvmfPkg: fold macros of unsupported GPE1 register block into Facp.aslc
In the next patch we're going to specify Extended Addresses of register
blocks in Generic Address Structure format. The GAS is easy to fill if we
want to posit either "unsupported" (all zero) or a given address in a
specific address space. However deriving "unsupported" just from a macro
expanding to zero is unwieldy, so let's avoid the need.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14154 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:37:29 +00:00
jljusten 1e69186a23 OvmfPkg: fold macros of unsupported PM2 control reg. block into Facp.aslc
Soon we're going to specify Extended Addresses of register blocks in
Generic Address Structure format. The GAS is easy to fill if we want to
posit either "unsupported" (all zero) or a given address in a specific
address space. However deriving "unsupported" just from a macro expanding
to zero is unwieldy, so let's avoid the need.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14153 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:37:15 +00:00
jljusten 8eb28fe796 OvmfPkg: fold macros of unsupported PM1b register blocks into Facp.aslc
Soon we're going to specify Extended Addresses of register blocks in
Generic Address Structure format. The GAS is easy to fill if we want to
posit either "unsupported" (all zero) or a given address in a specific
address space. However deriving "unsupported" just from a macro expanding
to zero is unwieldy, so let's avoid the need.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14152 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:36:55 +00:00
jljusten 69eeadbbd6 OvmfPkg: bump commonly used ACPI table revision numbers
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14151 6f19259b-4bc3-4df7-8a09-765794883524
2013-03-04 17:36:36 +00:00
jljusten 862379feff OvmfPkg: increase MEMFD size to 8MB
With reference to
<http://sourceforge.net/mailarchive/message.php?msg_id=30359322>:

"MEMFD is built so MAINFV's contents will be relocated during the build to
address 0x800000", and it "is a firmware volume with most OVMF code/data
uncompressed. [...] Increasing its size has a little impact on the size of
the resulting firmware image since the blank part of the firmware volume
will compress well."

Let's increase the size to 8MB, since the current limit can get in the way
(for example when building-in the Intel3.5 drivers for e1000 with
-D FD_SIZE_2MB -D NETWORK_ENABLE -D SECURE_BOOT_ENABLE).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14133 6f19259b-4bc3-4df7-8a09-765794883524
2013-02-14 19:21:56 +00:00
jljusten dd71f6e287 OvmfPkg LoadLinuxLib: Use kernel's EFI entry point where available
Usage of the EFI entry point was made feasible in the kernel
x64 boot protocol 2.12 where a 32-bit & 64-bit entry point
became well defined.

http://git.kernel.org/linus/09c205af

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14132 6f19259b-4bc3-4df7-8a09-765794883524
2013-02-14 19:21:39 +00:00
jljusten 25ca06f9a0 OvmfPkg LinuxBzimage.h: Update for kernel boot protocol 2.12
This was made available in:
http://git.kernel.org/linus/09c205af

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14131 6f19259b-4bc3-4df7-8a09-765794883524
2013-02-14 19:21:12 +00:00
jljusten 3d80db51f4 OvmfPkg/AcpiPlatformDxe: split S3/S4 package into bytes
This should be more compatible with AML parsers in practice
since older versions of ACPICA's OS support would not accept
the previous OVMF format (despite being spec compliant).
(For example, on OpenBSD 5.2 it caused a kernel crash)

ACPICA has fixed this issue in:
https://github.com/otcshare/acpica/commit/5869690a

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14130 6f19259b-4bc3-4df7-8a09-765794883524
2013-02-14 19:20:57 +00:00
jljusten 0c504abf90 OvmfPkg: set ActiveHigh polarity for the SCI with a dedicated link device
We cannot specify a pin-GSI connection for the SCI directly in the _PRT
because that implies ActiveLow polarity, clashing with both qemu and the
MADT we prepare.

With this patch the RHEL-6 guest logs the following:

    ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT]
    ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
    ACPI: PCI Interrupt Link [LNKA] (IRQs 5 10 *11)
    ACPI: PCI Interrupt Link [LNKB] (IRQs 5 10 *11)
    ACPI: PCI Interrupt Link [LNKC] (IRQs 5 *10 11)
    ACPI: PCI Interrupt Link [LNKD] (IRQs 5 *10 11)

The patch amends svn rev 13625. Testing it in a RHEL-6 guest, the problems
described in
<http://sourceforge.net/mailarchive/message.php?msg_id=29660862> do not
reappear.

The code is derived from Paolo Bonzini's patch (originally appearing as
SeaBIOS commit f64a472a, "acpi: reintroduce LNKS"). Said original patch is
copyrighted by Red Hat (our common employer), and it has been relicensed
<http://sourceforge.net/mailarchive/message.php?msg_id=30393854> to form
the basis of this derived patch for edk2. The latter is therefore

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14111 6f19259b-4bc3-4df7-8a09-765794883524
2013-01-28 16:55:38 +00:00
jljusten f940fea8b1 Revert "OvmfPkg: LoadLinuxLib: Use kernel's EFI entry point where available"
This reverts commit r14053. This change depends on changes to the
kernel which are not yet finalized/upstream.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14110 6f19259b-4bc3-4df7-8a09-765794883524
2013-01-28 16:55:22 +00:00
jljusten 29874a8c60 QemuFwCfgLib: Add QemuFwCfgWriteBytes() function
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14109 6f19259b-4bc3-4df7-8a09-765794883524
2013-01-28 16:54:55 +00:00
jljusten b5e243b75f OvmfPkg QemuFwCfgLib: Fix broken IA32 Microsoft assembler code
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14108 6f19259b-4bc3-4df7-8a09-765794883524
2013-01-28 16:54:27 +00:00
jljusten 0aedc542b6 OvmfPkg: update qemu-executable for IA32
Previously for IA32, we would only try to run qemu. Newer releases
of QEMU now have renamed the x86 qemu to qemu-system-i386.

Now, we search for:
1. qemu-system-i386
2. qemu-system-x86_64
3. qemu

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14101 6f19259b-4bc3-4df7-8a09-765794883524
2013-01-25 16:22:07 +00:00