]> git.proxmox.com Git - qemu.git/log
qemu.git
11 years agotarget-ppc: Split user only code out of mmu_helper.c
David Gibson [Tue, 12 Mar 2013 00:31:48 +0000 (00:31 +0000)]
target-ppc: Split user only code out of mmu_helper.c

mmu_helper.c is, for obvious reasons, almost entirely concerned with
softmmu builds of qemu.  However, it does contain one stub function which
is used when CONFIG_USER_ONLY=y - the user only versoin of
cpu_ppc_handle_mmu_fault, which always triggers an exception.  The entire
rest of the file is surrounded by #if !defined(CONFIG_USER_ONLY).

We clean this up by moving the user only stub into its own new file,
removing the ifdefs and building mmu_helper.c only when CONFIG_SOFTMMU
is set.  This also lets us remove the #define of cpu_handle_mmu_fault to
cpu_ppc_handle_mmu_fault - that name is only used from generic code for
user only - so we just name our split user version by the generic name.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash64: Implement Virtual Page Class Key Protection
David Gibson [Tue, 12 Mar 2013 00:31:47 +0000 (00:31 +0000)]
mmu-hash64: Implement Virtual Page Class Key Protection

Version 2.06 of the Power architecture describes an additional page
protection mechanism.  Each virtual page has a "class" (0-31) recorded in
the PTE.  The AMR register contains bits which can prohibit reads and/or
writes on a class by class basis.  Interestingly, the AMR is userspace
readable and writable, however user mode writes are masked by the contents
of the UAMOR which is privileged.

This patch implements this protection mechanism, along with the AMR and
UAMOR SPRs.  The architecture also specifies a hypervisor-privileged AMOR
register which masks user and supervisor writes to the AMR and UAMOR.  We
leave this out for now, since we don't at present model hypervisor mode
correctly in any case.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: fix 32-bit hosts]
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Merge translate and fault handling functions
David Gibson [Tue, 12 Mar 2013 00:31:46 +0000 (00:31 +0000)]
mmu-hash*: Merge translate and fault handling functions

ppc_hash{32,64}_handle_mmu_fault() is now the only caller of
ppc_hash{32,64{_translate(), so this patch combines them together.  This
means that instead of one returning a variety of non-obvious error codes
which then get translated into the various mmu exception conditions, we can
just generate the exceptions as we discover problems in the translation
path.  This also removes the last usage of mmu_ctx_hash{32,64}.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Don't use full ppc_hash{32, 64}_translate() path for get_phys_page_debug()
David Gibson [Tue, 12 Mar 2013 00:31:45 +0000 (00:31 +0000)]
mmu-hash*: Don't use full ppc_hash{32, 64}_translate() path for get_phys_page_debug()

Currently the hash mmu versionsof get_phys_page_debug() use the same
ppc64_hash64_translate() function to do the translation logic as the normal
mm fault handler code.

That sounds like a good idea, but has some complications. The debug path
doesn't need, or even want some parts of the full translation path, like
permissions checking.  Furthermore, the pte flags update included in the
normal path means that the debug call is not quite side effect free.

This patch, therefore, reimplements get_phys_page_debug as the minimal
required subset of the full translation path.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>`z
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Correctly mask RPN from hash PTE
David Gibson [Tue, 12 Mar 2013 00:31:44 +0000 (00:31 +0000)]
mmu-hash*: Correctly mask RPN from hash PTE

BEHAVIOUR CHANGE

At present we take the whole of word 1 of the hash PTE as the real page
number used to calculate the translated address.  This is incorrect,
because it leaves the flags from the low bits of PTE word 1 in place in the
rpm.  We mostly get away with that because the value is later masked by
TARGET_PAGE_MASK.

More recent 64-bit CPUs also have a small number of flag bits (PP0 and
KEY) in the top bits of PTE word 1.  Any guest which used those bits would
fail with the current code.

This patch fixes the problem by correctly masking out the RPN field of
PTE word 1.  This is safe, even for older CPUs which didn't have PP0 and
KEY, because although the RPN notionally extended to the very top of PTE
word 1, none of those CPUs actually implemented that many real address
bits.

We add analogous masking to the 32-bit code, even though it also doesn't
have the high flag bits, for consistency and clarity.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Clean up real address calculation
David Gibson [Tue, 12 Mar 2013 00:31:43 +0000 (00:31 +0000)]
mmu-hash*: Clean up real address calculation

More recent 64-bit hash MMUs support multiple page sizes, and PTEs for
large pages only include the offset of the whole large page.  But the qemu
tlb only handles pages of the base size (4k) so we need to break up the
large pages into 4k pieces for the qemu tlb.  To do that we have a somewhat
awkward piece of code that adds the folds address bits 4k and the page size
from the virtual address into the real address from the pte.

This patch simplifies this redefining the raddr output of
ppc_hash64_translate() to be the full real address of the faulting address,
rather than just the (4k) page offset.  Computing that turns out to be
simpler, and is fine for the caller, since it already masks with
TARGET_PAGE_MASK before inserting into the qemu tlb.

The multiple page size complication doesn't exist for 32-bit hash mmus, but
we make an analogous cleanup there for consistency.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Clean up PTE flags update
David Gibson [Tue, 12 Mar 2013 00:31:42 +0000 (00:31 +0000)]
mmu-hash*: Clean up PTE flags update

Currently the ppc_hash{32,64}_pte_update_flags() helper functions update a
PTE's referenced and changed bits as necessary to reflect the access.  It
is somewhat long winded, though.  This patch open codes them in their
(single) callers, in a simpler way.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash64: Factor SLB N bit into permissions bits
David Gibson [Tue, 12 Mar 2013 00:31:41 +0000 (00:31 +0000)]
mmu-hash64: Factor SLB N bit into permissions bits

BEHAVIOUR CHANGE

Currently, for 64-bit hash mmu, the execute protection bit placed into the
qemu tlb is based only on the N (No execute) bit from the PTE.  However,
No Execute can also be set at the segment level.  We do check this on
execute faults, but this still means we could incorrectly allow execution
of code from a No Execute segment, if a prior read or write fault caused
the page to be loaded into the qemu tlb with PROT_EXEC set.

To correct this, we (re-)check the segment level no execute permission when
generating the protection bits for the qemu tlb.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Clean up permission checking
David Gibson [Tue, 12 Mar 2013 00:31:40 +0000 (00:31 +0000)]
mmu-hash*: Clean up permission checking

Currently checking of PTE permission bits is split messily amongst
ppc_hash{32,64}_pp_check(), ppc_hash{32,64}_check_prot() and their callers.
This patch cleans this up to have the new function
ppc_hash{32,64}_pte_prot() compute the page permissions from the SLBE (for
64-bit) or segment register (32-bit) and the pte.  A greatly simplified
version of the actual permissions check is then open coded in the callers.

The 32-bit version of ppc_hash32_pte_prot() is implemented in terms of
ppc_hash32_pp_prot(), a renamed and slightly cleaned up version of the old
ppc_hash32_pp_check(), which is also used for checking BAT permissions on
the 601.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Remove nx from context structure
David Gibson [Tue, 12 Mar 2013 00:31:39 +0000 (00:31 +0000)]
mmu-hash32: Remove nx from context structure

Previous cleanups have meant the nx field of the mmu_ctx_hash32 structure
is now only used within ppc_hash32_translate(), and so it can be replaced
by a local variable.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Don't update PTE flags when permission is denied
David Gibson [Tue, 12 Mar 2013 00:31:38 +0000 (00:31 +0000)]
mmu-hash*: Don't update PTE flags when permission is denied

BEHAVIOUR CHANGE

Currently if ppc_hash{32,64}_translate() finds a PTE matching the given
virtual address, it will always update the PTE's R & C (Referenced and
Changed) bits.  This happens even if the PTE's permissions mean we are
about to deny the translation.

This is clearly a bug, although we get away with it because:
  a) It will only incorrectly set, never reset the bits, which should not
cause guest correctness problems.
  b) Linux guests never use the R & C bits anyway.

This patch fixes the behaviour, only updating R & C when access is granted
by the PTE.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Don't look up page tables on BAT permission error
David Gibson [Tue, 12 Mar 2013 00:31:37 +0000 (00:31 +0000)]
mmu-hash32: Don't look up page tables on BAT permission error

BEHAVIOUR CHANGE

Currently, on any failure translating an address with BATs, we proceed to
normal segment and page table translation.  That's incorrect if the
BAT error was due to permissions, rather than not finding a matching BAT.
We've gotten away with it because a guest would not usually put
translations for the same address in both BATs and page table.  Nonetheless
this patch corrects the logic, only doing page table lookup if no BAT
is found.  A matching BAT with bad permissions will now correctly trigger
an exception.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Cleanup BAT lookup
David Gibson [Tue, 12 Mar 2013 00:31:36 +0000 (00:31 +0000)]
mmu-hash32: Cleanup BAT lookup

This patch makes a general cleanup of the ppc_hash32_get_bat() function,
renaming it to ppc_hash32_bat_lookup().  In particular, the new function
only looks for a matching BAT, with the permissions check from the old
function moved to the caller.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Clean up BAT matching logic
David Gibson [Tue, 12 Mar 2013 00:31:35 +0000 (00:31 +0000)]
mmu-hash32: Clean up BAT matching logic

The code to search for a matching BAT for a virtual address is somewhat
longwinded and awkward.  In particular, it relies on seperate size and
validity information being returned from the hash32_bat_size() function
(and 601 specific variant).

We simplify this by having hash32_bat_size() return instead a mask of the
virtual address bits to match, and 0 for invalid (since a BAT can never
match the entire address space).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Split BAT size logic from permissions logic
David Gibson [Tue, 12 Mar 2013 00:31:34 +0000 (00:31 +0000)]
mmu-hash32: Split BAT size logic from permissions logic

hash32_bat_size_prot() and its 601 variant, as the name suggests, returns
both a BAT's size - needed to search for a matching BAT - and its
permissions, only relevant once a matching BAT has been located.

There's no particular advantage to combining these, so we split these roles
into seperate functions for clarity.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Remove odd pointer usage from BAT code
David Gibson [Tue, 12 Mar 2013 00:31:33 +0000 (00:31 +0000)]
mmu-hash32: Remove odd pointer usage from BAT code

In the code for handling BATs, the hash32_bat_size_prot() and
hash32_bat_601_size_prot() functions are passed the BAT contents by
reference (pointer) for no clear reason, since they only need the values
within.

This patch removes this odd usage, and uses the resulting change to clean
up the caller slightly.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Fold pte_check*() logic into caller
David Gibson [Tue, 12 Mar 2013 00:31:32 +0000 (00:31 +0000)]
mmu-hash*: Fold pte_check*() logic into caller

With previous cleanups made, the 32-bit and 64-bit pte_check*() functions
are pretty trivial and only have one call site.  This patch therefore
clarifies the overall code flow by folding those functions into their
call site.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash64: Clean up ppc_hash64_htab_lookup()
David Gibson [Tue, 12 Mar 2013 00:31:31 +0000 (00:31 +0000)]
mmu-hash64: Clean up ppc_hash64_htab_lookup()

This patch makes a general cleanup of the address mangling logic in
ppc_hash64_htab_lookup().  In particular it now avoids repeatedly switching
on the segment size.  The lack of SLB and multiple segment sizes on 32-bit
means an analogous cleanup is not needed there.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Remove permission checking from find_pte{32, 64}()
David Gibson [Tue, 12 Mar 2013 00:31:30 +0000 (00:31 +0000)]
mmu-hash*: Remove permission checking from find_pte{32, 64}()

find_pte{32,64}() are poorly named, since they both find a PTE and do
permissions checking of it.  This patch makes them only locate a matching
PTE, moving the permission checking and other logic to the caller.  We
rename the resulting search functions ppc_hash{32,64}_htab_lookup().

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Make find_pte{32, 64} do more of the job of finding ptes
David Gibson [Tue, 12 Mar 2013 00:31:29 +0000 (00:31 +0000)]
mmu-hash*: Make find_pte{32, 64} do more of the job of finding ptes

find_pte{32,64}() are not particularly well named.  They only "find" a PTE
within a given PTE group, and they also do permissions checking and other
things.

This patch makes it somewhat close to matching the name, by folding the
search of both primary and secondary hash bucket into it, along with the
various address bit shuffling to determine the right hash buckets.

In the 32-bit case we also remove the code for splitting large pages into
4k pieces for the qemu tlb, since no 32-bit hash MMUs support multiple page
sizes.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Separate PTEG searching from permissions checking
David Gibson [Tue, 12 Mar 2013 00:31:28 +0000 (00:31 +0000)]
mmu-hash*: Separate PTEG searching from permissions checking

find_pte{32,64{() do several things.  First they search through a PTEG
ooking for a PTE matching our virtual address.  Then they do permissions
checking and other processing on that PTE.

This patch separates the search by VA out from the rest.  The search is
combined with the pte{32,64}_match() functions into new
ppc_has{32,64}_pteg_search() functions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Don't keep looking for PTEs after we find a match
David Gibson [Tue, 12 Mar 2013 00:31:27 +0000 (00:31 +0000)]
mmu-hash*: Don't keep looking for PTEs after we find a match

BEHAVIOUR CHANGE

The ppc hash mmu hashes each virtual address to a primary and secondary
possible hash bucket (aka PTE group or PTEG) each with 8 PTEs.  Then we
need a linear search through the PTEs to find the correct one for the
virtual address we're translating.

It is a programming error for the guest to insert multiple PTEs mapping the
same virtual address into a PTEG - in this case the ppc architecture says
the MMU can either act as if just one was present, or give a machine check.
Currently our code takes the first matching PTE in a PTEG if it finds a
successful translation.  But if a matching PTE is found, but permission
bits don't allow the access, we keep looking through the PTEG, checking
that any other matching PTEs contain an identical translation.

That behaviour is perhaps not exactly wrong, but it's certainly not useful.
This patch changes it to always just find the first matching PTE in a PTEG.

In addition, if we get a permissions problem on the primary PTEG, we then
search the secondary PTEG.  This is incorrect - a permission denying PTE
in the primary PTEG should not be overwritten by an access granting PTE in
the secondary (although again, it would be a programming error for the
guest to set up such a situation anyway).  So additionally we update the
code to only search the secondary PTEG if no matching PTE is found in the
primary at all.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Cleanup segment-level NX check
David Gibson [Tue, 12 Mar 2013 00:31:26 +0000 (00:31 +0000)]
mmu-hash*: Cleanup segment-level NX check

On the ppc hash mmus, no-execute can be set at the segment level (on more
recent 64-bit hash mmus it can also be set at the page level).  This patch
separates out this check to make it clearer what is going on, and avoiding
excessive indentation of the remaining translation code.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Split direct store segment handling into a helper
David Gibson [Tue, 12 Mar 2013 00:31:25 +0000 (00:31 +0000)]
mmu-hash32: Split direct store segment handling into a helper

This further separates the unusual case handling of direct store segments
from the main translation path by moving its logic into a helper function,
with some tiny cleanups along the way.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash32: Split out handling of direct store segments
David Gibson [Tue, 12 Mar 2013 00:31:24 +0000 (00:31 +0000)]
mmu-hash32: Split out handling of direct store segments

At present a large chunk of ppc_hash32_translate() is taken up with an
ugly if selecting between direct store segments (hardly ever used) and
normal paged segments.  This patch clarifies the flow of code by
handling direct store segments immediately then returning, leaving the
straight line code to describe the normal MMU path.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Combine ppc_hash{32, 64}_get_physical_address and get_segment{32, 64}()
David Gibson [Tue, 12 Mar 2013 00:31:23 +0000 (00:31 +0000)]
mmu-hash*: Combine ppc_hash{32, 64}_get_physical_address and get_segment{32, 64}()

After previous work, ppc_hash{32,64}_get_physical_address() are almost
trivial wrappers around get_segment{32,64}() which does nearly all the work of
translating an address according to the hash mmu model.  Therefore combine the
two functions into one, under the better name of
ppc_hash{32,64}_translate().

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Remove eaddr field from mmu_ctx_hash{32, 64}
David Gibson [Tue, 12 Mar 2013 00:31:22 +0000 (00:31 +0000)]
mmu-hash*: Remove eaddr field from mmu_ctx_hash{32, 64}

The eaddr field of mmu_ctx_hash{32,64} is effectively just used to pass the
effective address from get_segment{32,64}() to find_pte{32,64}().  Just
pass it as a normal parameter instead.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash64: Remove nx from mmu_ctx_hash64
David Gibson [Tue, 12 Mar 2013 00:31:21 +0000 (00:31 +0000)]
mmu-hash64: Remove nx from mmu_ctx_hash64

The nx field in mmu_ctx_hash64 is used in two different functions.  But its
used for slightly different things in each place, and the value is never
propagated between them.  In other words, it might as well be two local
variables.  This patch makes it so.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Reduce use of access_type
David Gibson [Tue, 12 Mar 2013 00:31:20 +0000 (00:31 +0000)]
mmu-hash*: Reduce use of access_type

In ppc env->access_type is updated by e.g. integer load/stores with
ACCESS_INT floating point load/stores with ACCESS_FLOAT and so forth.  In
hash mmu fault paths it can also b set to ACCESS_CODE for instruction
fetch accesses.

But the only place which uses anything more of the access_type than
whether it is instruction fetch or data access is the direct store segment
handling.  Instruction versus data access can be more simply determined
from the rw value passed down from the top.

This changes the code to use rw in preference to checking access_type.
For the 32-bit case there is a small amount of code (for direct store
segments) that still needs the full access type.  Instead of passing it
all the way down the stack, we retrieve it from the env structure, which
is where it came anyway, before this patch.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Add hash pte load/store helpers
David Gibson [Tue, 12 Mar 2013 00:31:19 +0000 (00:31 +0000)]
mmu-hash*: Add hash pte load/store helpers

On real hardware the ppc hash page table is stored in memory; accordingly
our mmu emulation code can read a hash page table in guest memory.  But,
when paravirtualized under PAPR, the real hash page table is in host
memory, accessible to the guest only via hypercalls.  We model this by
also allowing the MMU emulation code to access a specially allocated hash
page table outside the guest's memory image. At present these two options
are implemented with some ugly conditionals at each access point in the mmu
emulation code.  In the implementation of the PAPR hypercalls, we assume
the external hash table.

This patch cleans things up by adding helpers to load and store from the
hash table for both 32-bit and 64-bit hash mmus.  The 64-bit versions
handle both the in-guest-memory and outside guest memory cases.  The 32-bit
versions only handle the in-guest-memory case since no 32-bit systems can
have an external hash table at present.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agommu-hash*: Add header file for definitions
David Gibson [Tue, 12 Mar 2013 00:31:18 +0000 (00:31 +0000)]
mmu-hash*: Add header file for definitions

Currently cpu.h contains a number of definitions relating to the 64-bit
hash MMU.  Some are used in the MMU emulation code, but some are only used
in the spapr MMU management hcall implementations.

This patch moves these definitions (except for a few that are needed
more widely) into mmu-hash64.h header, shared between the MMU emulation
code and the spapr hcall code.  The MMU emulation code is also updated to
actually use a number of those definitions in place of hard coded
constants.

Similarly, we add new analogous definitions to mmu-hash32.h and use those
in place of many hard-coded constants in mmu-hash32.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[agraf: fix 32-bit hosts]
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: mmu_ctx_t should not be a global type
David Gibson [Tue, 12 Mar 2013 00:31:17 +0000 (00:31 +0000)]
target-ppc: mmu_ctx_t should not be a global type

mmu_ctx_t is currently defined in cpu.h.  However it is used for temporary
information relating to mmu translation, and is only used in mmu_helper.c
and (now) mmu-hash{32,64}.c.  Furthermore it contains information which
should be specific to particular MMU types.  Therefore, move its definition
to mmu_helper.c.  mmu-hash{32,64}.c are converted to use new data types
private to the relevant MMUs (identical to mmu_ctx_t for now, but that will
change in future patches).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle BAT code for 32-bit hash MMUs
David Gibson [Tue, 12 Mar 2013 00:31:16 +0000 (00:31 +0000)]
target-ppc: Disentangle BAT code for 32-bit hash MMUs

The functions for looking up BATs (Block Address Translation - essentially
a level 0 TLB) are shared between the classic 32-bit hash MMUs and the
6xx style software loaded TLB implementations.

This patch splits out a copy for the 32-bit hash MMUs, to facilitate
cleaning it up.  The remaining version is left, but cleaned up slightly
to no longer deal with PowerPC 601 peculiarities (601 has a hash MMU).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Don't share get_pteg_offset() between 32 and 64-bit
David Gibson [Tue, 12 Mar 2013 00:31:15 +0000 (00:31 +0000)]
target-ppc: Don't share get_pteg_offset() between 32 and 64-bit

The get_pteg_offset() helper function is currently shared between 32-bit
and 64-bit hash mmus, taking a parameter for the hash pte size.  In the
64-bit paths, it's only called in one place, and it's a trivial
calculation.  This patch, therefore, open codes it for 64-bit.  The
remaining version, which is used in two places is made 32-bit only and
moved to mmu-hash32.c.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle hash mmu helper functions
David Gibson [Tue, 12 Mar 2013 00:31:14 +0000 (00:31 +0000)]
target-ppc: Disentangle hash mmu helper functions

The newly separated paths for hash mmus rely on several helper functions
which are still shared with 32-bit hash mmus: pp_check(), check_prot() and
pte_update_flags().  While these don't have ugly ifdefs on the mmu type,
they're not very well thought out, so sharing them impedes cleaning up the
hash mmu paths.  For now, put near-duplicate versions into mmu-hash64.c and
mmu-hash32.c, leaving the old version in mmu_helper.c for 6xx software
loaded tlb implementations.  The hash 32 and software loaded
implementations are simplfied slightly, using the fact that no 32-bit CPUs
implement the 3rd page protection bit.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle hash mmu versions of cpu_get_phys_page_debug()
David Gibson [Tue, 12 Mar 2013 00:31:13 +0000 (00:31 +0000)]
target-ppc: Disentangle hash mmu versions of cpu_get_phys_page_debug()

cpu_get_phys_page_debug() is a trivial wrapper around
get_physical_address().  But even the signature of
get_physical_address() has some things we'd like to clean up on a
per-mmu basis, so this patch moves the test on mmu model out to
cpu_get_phys_page_debug(), moving the version for 64-bit hash MMUs out
to mmu-hash64.c and the version for 32-bit hash MMUs to mmu-hash32.c

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle hash mmu paths for cpu_ppc_handle_mmu_fault
David Gibson [Tue, 12 Mar 2013 00:31:12 +0000 (00:31 +0000)]
target-ppc: Disentangle hash mmu paths for cpu_ppc_handle_mmu_fault

cpu_ppc_handle_mmu_fault() calls get_physical_address() (whose behaviour
depends on MMU type) then, if that fails, issues an appropriate exception
- which again has a number of dependencies on MMU type.

This patch starts converting cpu_ppc_handle_mmu_fault() to have a
single switch on MMU type, calling MMU specific fault handler
functions which deal with both translation and exception delivery
appropriately for the MMU type.  We convert 32-bit and 64-bit hash
MMUs to this new model, but the existing code is left in place for
other MMU types for now.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle get_physical_address() paths
David Gibson [Tue, 12 Mar 2013 00:31:11 +0000 (00:31 +0000)]
target-ppc: Disentangle get_physical_address() paths

Depending on the MSR state, for 64-bit hash MMUs, get_physical_address
can either call check_physical (which has further tests for mmu type)
or get_segment64.  Similarly for 32-bit hash MMUs we can either call
check_physucal or get_bat() and get_segment32().

This patch splits off the whole get_physical_addresss() path for hash
MMUs into 32-bit and 64-bit versions, handling real mode correctly for
such MMUs without going to check_physical and rechecking the mmu type.
Correspondingly, the hash MMU specific paths in check_physical() are
removed.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Rework get_physical_address()
David Gibson [Tue, 12 Mar 2013 00:31:10 +0000 (00:31 +0000)]
target-ppc: Rework get_physical_address()

Currently get_physical_address() first checks to see if translation is
enabled in the MSR, then in the translation on case switches on the mmu
type.  Except that for BookE MMUs, translation is always on, and so it
has to switch in the "translation off" case as well and do the same thing
as the translation on path for those MMUs.  Plus, even translation off
doesn't behave exactly the same on the various MMU types so there are
further mmu type checks in the "translation off" path.

As a first step to cleaning this up, this patch moves the switch on mmu
type to the top level, then makes the translation on/off check just for
those mmu types where it is meaningful.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle get_segment()
David Gibson [Tue, 12 Mar 2013 00:31:09 +0000 (00:31 +0000)]
target-ppc: Disentangle get_segment()

The poorly named get_segment() function handles most of the address
translation logic for hash-based MMUs.  It has many ugly conditionals on
whether the MMU is 32-bit or 64-bit.

This patch splits the function into 32 and 64-bit versions, using the
switch on mmu_type that's already in the caller
(get_physical_address()) to select the right one.  Most of the
original function remains in mmu_helper.c to support the 6xx software
loaded TLB implementations (cleaning those up is a project for another
day).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle find_pte()
David Gibson [Tue, 12 Mar 2013 00:31:08 +0000 (00:31 +0000)]
target-ppc: Disentangle find_pte()

32-bit and 64-bit hash MMU implementations currently share a find_pte
function.  This results in a whole bunch of ugly conditionals in the shared
function, and not all that much actually shared code.

This patch separates out the 32-bit and 64-bit versions, putting then
in mmu-hash64.c and mmu-has32.c, and removes the conditionals from
both versions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Disentangle pte_check()
David Gibson [Tue, 12 Mar 2013 00:31:07 +0000 (00:31 +0000)]
target-ppc: Disentangle pte_check()

Currently support for both 32-bit and 64-bit hash MMUs share an
implementation of pte_check.  But there are enough differences that this
means the shared function has several very ugly conditionals on "is_64b".

This patch cleans things up by separating out the 64-bit version
(putting it into mmu-hash64.c) and the 32-bit hash version (putting it
in mmu-hash32.c).  Another copy remains in mmu_helper.c, which is used
for the 6xx software loaded TLB paths.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Move SLB handling into a mmu-hash64.c
David Gibson [Tue, 12 Mar 2013 00:31:06 +0000 (00:31 +0000)]
target-ppc: Move SLB handling into a mmu-hash64.c

As a first step to disentangling the handling for 64-bit hash MMUs from
the rest, we move the code handling the Segment Lookaside Buffer (SLB)
(which only exists on 64-bit hash MMUs) into a new mmu-hash64.c file.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Remove address check for logging
David Gibson [Tue, 12 Mar 2013 00:31:05 +0000 (00:31 +0000)]
target-ppc: Remove address check for logging

One LOG_MMU statement in mmu_helper.c has an odd check on the effective
address being translated.  I can see no reason for this; I suspect it was
a debugging hack from long ago.  This patch removes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Trivial cleanups in mmu_helper.c
David Gibson [Tue, 12 Mar 2013 00:31:04 +0000 (00:31 +0000)]
target-ppc: Trivial cleanups in mmu_helper.c

This removes the never-used pte64_invalidate() function, and makes
ppcmas_tlb_check() static, since it's only used within that file.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Remove vestigial PowerPC 620 support
David Gibson [Tue, 12 Mar 2013 00:31:03 +0000 (00:31 +0000)]
target-ppc: Remove vestigial PowerPC 620 support

The PowerPC 620 was the very first 64-bit PowerPC implementation, but
hardly anyone ever actually used the chips.  qemu notionally supports the
620, but since we don't actually have code to implement the segment table,
the support is broken (quite likely in other ways too).

This patch, therefore, removes all remaining pieces of 620 support, to
stop it cluttering up the platforms we actually care about.  This includes
removing support for the ASR register, used only on segment table based
machines.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agoPPC/GDB: handle read and write of fpscr
Fabien Chouteau [Tue, 19 Mar 2013 07:41:53 +0000 (07:41 +0000)]
PPC/GDB: handle read and write of fpscr

Although the support of this register may be uncomplete, there are no
reason to prevent the debugger from reading or writing it.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agopseries: Move XICS initialization before cpu initialization
David Gibson [Wed, 13 Mar 2013 15:53:28 +0000 (15:53 +0000)]
pseries: Move XICS initialization before cpu initialization

Currently, the pseries machine initializes the cpus, then the XICS
interrupt controller.  However, to support the upcoming in-kernel XICS
implementation we will need to initialize the irq controller before the
vcpus.  This patch makes the necesssary rearrangement.  This means the
xics init code can no longer auto-detect the number of cpus ("interrupt
servers" in XICS terminology) and so we must pass that in explicitly from
the platform code.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agotarget-ppc: Remove CONFIG_PSERIES dependency in kvm.c
David Gibson [Wed, 13 Mar 2013 15:53:27 +0000 (15:53 +0000)]
target-ppc: Remove CONFIG_PSERIES dependency in kvm.c

target-ppc/kvm.c has an #ifdef on CONFIG_PSERIES, for the handling of
KVM exits due to a PAPR hypercall from the guest.  However, since commit
e4c8b28cde12d01ada8fe869567dc5717a2dfcb7 "ppc: express FDT dependency of
pSeries and e500 boards via default-configs/", this hasn't worked properly.
That patch altered the configuration setup so that although CONFIG_PSERIES
is visible from the Makefiles, it is not visible from C files.  This broke
the pseries machine when KVM is in use.

This patch makes a quick and dirty fix, by removing the CONFIG_PSERIES
dependency, replacing it with TARGET_PPC64 (since removing it entirely
leads to type mismatch errors).  Technically this breaks the build when
configured with --disable-fdt, since that disables CONFIG_PSERIES on
TARGET_PPC64.  However, it turns out the build was already broken in that
case, so this fixes pseries kvm without breaking anything extra.  I'm
looking into how to fix that build breakage, but I don't think that need
delay applying this patch.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agopseries: Remove "busname" property for PCI host bridge
David Gibson [Wed, 13 Mar 2013 15:53:25 +0000 (15:53 +0000)]
pseries: Remove "busname" property for PCI host bridge

Currently the "spapr-pci-host-bridge" device has a "busname" property which
can be used to override the default assignment of qbus names for the bus
subordinate to the PHB.  We use that for the default primary PCI bus, to
make libvirt happy, which expects there to be a bus named simply "pci".
The default qdev core logic would name the bus "pci.0", and the pseries
code would otherwise name it "pci@800000020000000" which is the name it
is given in the device tree based on its BUID.

The "busname" property is rather clunky though, so this patch simplifies
things by just using a special case hack for the default PHB, setting
busname to "pci" when index=0.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agopseries: Fix breakage in CPU QOM conversion
David Gibson [Thu, 14 Mar 2013 17:59:29 +0000 (17:59 +0000)]
pseries: Fix breakage in CPU QOM conversion

Commit 259186a7d2f7184efc96ae99bc5658e6159f53ad "cpu: Move halted and
interrupt_request fields to CPUState" broke the pseries machine.  That's
because it uses CPU() instead of ENV_GET_CPU() to convert from the global
first_cpu pointer (still a CPUArchState) to a CPUState.  This patch fixes
the breakage.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
11 years agomicroblaze: Ignore non-cpu accesses to unmapped areas
Edgar E. Iglesias [Tue, 19 Mar 2013 16:34:47 +0000 (17:34 +0100)]
microblaze: Ignore non-cpu accesses to unmapped areas

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
11 years agoMerge remote-tracking branch 'kraxel/ipxe.2' into staging
Anthony Liguori [Tue, 19 Mar 2013 13:01:07 +0000 (08:01 -0500)]
Merge remote-tracking branch 'kraxel/ipxe.2' into staging

# By Gerd Hoffmann
# Via Gerd Hoffmann
* kraxel/ipxe.2:
  Switch to efi-enabled nic roms by default
  Add efi rom binaries
  Add Makefile rules to build nic rom binaries with efi support
  Update ipxe submodule to latest master
  Add Makefile rules to build nic rom binaries

11 years agoadd a boot option to do strict boot
Amos Kong [Tue, 19 Mar 2013 06:23:27 +0000 (14:23 +0800)]
add a boot option to do strict boot

Seabios already added a new device type to halt booting.
Qemu can add "HALT" at the end of bootindex string, then
seabios will halt booting after trying to boot from all
selected devices.

This patch added a new boot option to configure if boot
from un-selected devices.

This option only effects when boot priority is changed by
bootindex options, the old style(-boot order=..) will still
try to boot from un-selected devices.

v2: add HALT entry in get_boot_devices_list()
v3: rebase to latest qemu upstream

Signed-off-by: Amos Kong <akong@redhat.com>
Message-id: 1363674207-31496-1-git-send-email-akong@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoui/cocoa.m: Fix compile failures introduced by recent console changes
Peter Maydell [Mon, 18 Mar 2013 20:28:21 +0000 (20:28 +0000)]
ui/cocoa.m: Fix compile failures introduced by recent console changes

Fix various compilation failures introduced by the recent console
changes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363638501-29603-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Tue, 19 Mar 2013 12:58:44 +0000 (07:58 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

# By Stefan Hajnoczi (2) and others
# Via Kevin Wolf
* kwolf/for-anthony:
  virtio-blk: Do not segfault fault if failed to initialize dataplane
  qemu-iotests: add 052 BDRV_O_SNAPSHOT test
  block: fix BDRV_O_SNAPSHOT protocol detection
  qcow2: Fix segfault in qcow2_invalidate_cache
  sheepdog: show error message for halt status

11 years agochar: Fix return type of qemu_chr_fe_add_watch()
Kevin Wolf [Tue, 19 Mar 2013 12:38:09 +0000 (13:38 +0100)]
char: Fix return type of qemu_chr_fe_add_watch()

qemu_chr_fe_add_watch() can return negative errors, therefore it must
not have an unsigned return type. For consistency with other
qemu_chr_fe_* functions, this uses a standard C int instead of glib
types.

In situations where qemu_chr_fe_add_watch() is falsely assumed to have
succeeded, the serial ports would go into a state where it never becomes
ready for transmitting more data; this is fixed by this patch.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agofix monitor
Gerd Hoffmann [Tue, 19 Mar 2013 09:57:56 +0000 (10:57 +0100)]
fix monitor

chardev flow control broke monitor, fix it by adding watch support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk: Do not segfault fault if failed to initialize dataplane
Dunrong Huang [Tue, 19 Mar 2013 08:27:29 +0000 (16:27 +0800)]
virtio-blk: Do not segfault fault if failed to initialize dataplane

$ ~/usr/bin/qemu-system-x86_64 -enable-kvm -m 1024 -drive if=none,id=drive0,cache=none,aio=native,format=raw,file=/root/Image/centos-6.4.raw -device virtio-blk-pci,drive=drive0,scsi=off,x-data-plane=on,config-wce=on # make dataplane fail to initialize
qemu-system-x86_64: -device virtio-blk-pci,drive=drive0,scsi=off,x-data-plane=on,config-wce=on: device is incompatible with x-data-plane, use config-wce=off
*** glibc detected *** /root/usr/bin/qemu-system-x86_64: free(): invalid pointer: 0x00007f001fef12f8 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7d776)[0x7f00153a5776]
/root/usr/bin/qemu-system-x86_64(+0x2c34ec)[0x7f001cf5b4ec]
/root/usr/bin/qemu-system-x86_64(+0x342f9a)[0x7f001cfdaf9a]
/root/usr/bin/qemu-system-x86_64(+0x33694e)[0x7f001cfce94e]
....................

 (gdb) bt
 #0  0x00007f3bf3a12015 in raise () from /lib64/libc.so.6
 #1  0x00007f3bf3a1348b in abort () from /lib64/libc.so.6
 #2  0x00007f3bf3a51a4e in __libc_message () from /lib64/libc.so.6
 #3  0x00007f3bf3a57776 in malloc_printerr () from /lib64/libc.so.6
 #4  0x00007f3bfb60d4ec in free_and_trace (mem=0x7f3bfe0129f8) at vl.c:2786
 #5  0x00007f3bfb68cf9a in virtio_cleanup (vdev=0x7f3bfe0129f8) at /root/Develop/QEMU/qemu/hw/virtio.c:900
 #6  0x00007f3bfb68094e in virtio_blk_device_init (vdev=0x7f3bfe0129f8) at /root/Develop/QEMU/qemu/hw/virtio-blk.c:666
 #7  0x00007f3bfb68dadf in virtio_device_init (qdev=0x7f3bfe0129f8) at /root/Develop/QEMU/qemu/hw/virtio.c:1092
 #8  0x00007f3bfb50da46 in device_realize (dev=0x7f3bfe0129f8, err=0x7fff479c9258) at hw/qdev.c:176
.............................

In virtio_blk_device_init(), the memory which vdev point to is a static
member of "struct VirtIOBlkPCI", not heap memory, and it does not
get freed. So we shoule use virtio_common_cleanup() to clean this VirtIODevice
rather than virtio_cleanup(), which attempts to free the vdev.

This error was introduced by commit 05ff686536f408ba6e8426b1b54d25bd3379fda2
recently.

Signed-off-by: Dunrong Huang <huangdr@cloud-times.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add 052 BDRV_O_SNAPSHOT test
Stefan Hajnoczi [Mon, 18 Mar 2013 16:58:54 +0000 (17:58 +0100)]
qemu-iotests: add 052 BDRV_O_SNAPSHOT test

Check that writes to an image opened with BDRV_O_SNAPSHOT do not modify
the underlying image file.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: fix BDRV_O_SNAPSHOT protocol detection
Stefan Hajnoczi [Mon, 18 Mar 2013 16:58:53 +0000 (17:58 +0100)]
block: fix BDRV_O_SNAPSHOT protocol detection

realpath(3) is used to get an absolute path to the image file when
creating a -drive snapshot=on temporary qcow2.  This does not work for
protocols since their filenames ("proto:foo:...") do not correspond to
file system paths.

Commit 7c96d46ec245d73fd76726588409f9abe4bd5dc1 ("Let snapshot work with
protocols") skipped realpath(3) for protocols.  Later on the "raw"
format was introduced and broke the check.

Use path_has_protocol(filename) to decide if this image uses a protocol
or a filename.

Reported-by: Richard Jones <rjones@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: Fix segfault in qcow2_invalidate_cache
Kevin Wolf [Mon, 18 Mar 2013 12:08:10 +0000 (13:08 +0100)]
qcow2: Fix segfault in qcow2_invalidate_cache

Need to pass an options QDict to qcow2_open() now. This fixes a segfault
on the migration target with qcow2.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agosheepdog: show error message for halt status
Liu Yuan [Mon, 18 Mar 2013 06:27:55 +0000 (14:27 +0800)]
sheepdog: show error message for halt status

Sheepdog (neither quorum nor unsafe mode) will refuse to serve IO requests when
number of alive nodes is less than that of copies specified by users. This will
return 0x19 to QEMU client which currently doesn't recognize it.

This patch adds an error description when QEMU client receives it, other than
plainly printing 'Invalid error code'

Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agovirtio-blk: cleanup: remove qdev field.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:28 +0000 (17:37 +0100)]
virtio-blk: cleanup: remove qdev field.

The qdev field is no longer needed, just drop it.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-12-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk: cleanup: QOM cast
KONRAD Frederic [Mon, 18 Mar 2013 16:37:27 +0000 (17:37 +0100)]
virtio-blk: cleanup: QOM cast

Use QOM casts inside virtio-blk.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-11-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk: cleanup: init and exit functions.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:26 +0000 (17:37 +0100)]
virtio-blk: cleanup: init and exit functions.

As all virtio-blk-* are switched to the new API, we can remove the separate
init/exit for the old API.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-10-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk-ccw switch to new API.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:25 +0000 (17:37 +0100)]
virtio-blk-ccw switch to new API.

Here the virtio-ccw-s390 is modified for the new API. The device
virtio-ccw-s390 extends virtio-ccw-device as before. It creates and
connects a virtio-ccw during the init. The properties are not modified.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-9-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk-s390: switch to the new API.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:24 +0000 (17:37 +0100)]
virtio-blk-s390: switch to the new API.

Here the virtio-blk-s390 is modified for the new API. The device
virtio-blk-s390 extends virtio-s390-device as before. It creates and
connects a virtio-blk during the init. The properties are not modified.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-8-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk-pci: switch to new API.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:23 +0000 (17:37 +0100)]
virtio-blk-pci: switch to new API.

Here the virtio-blk-pci is modified for the new API. The device
virtio-blk-pci extends virtio-pci. It creates and connects a virtio-blk
during the init. The properties are not changed.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-7-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk: add the virtio-blk device.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:22 +0000 (17:37 +0100)]
virtio-blk: add the virtio-blk device.

Create virtio-blk which extends virtio-device, so it can be connected on
virtio-bus.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-6-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-blk: don't use pointer for configuration.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:21 +0000 (17:37 +0100)]
virtio-blk: don't use pointer for configuration.

The configuration field must not be a pointer as it will be used for virtio-blk
properties. So *blk is replaced by blk in VirtIOBlock structure.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1363624648-16906-5-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-pci: fix hot unplug.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:20 +0000 (17:37 +0100)]
virtio-pci: fix hot unplug.

Hot unplug failed because it tried to free the virtio device two times.

This fix the issue by removing the call to virtio_bus_destroy_device.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Message-id: 1363624648-16906-4-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-x-bus: fix allow_hotplug assertion.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:19 +0000 (17:37 +0100)]
virtio-x-bus: fix allow_hotplug assertion.

This set allow_hotplug for each existing virtio-x-bus, allowing the
refactored devices to be hot pluggable.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Message-id: 1363624648-16906-3-git-send-email-fred.konrad@greensocs.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio: make virtio device's structures public.
KONRAD Frederic [Mon, 18 Mar 2013 16:37:18 +0000 (17:37 +0100)]
virtio: make virtio device's structures public.

These structures must be made public to avoid two memory allocations for
refactored virtio devices.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Message-id: 1363624648-16906-2-git-send-email-fred.konrad@greensocs.com

Changes V4 <- V3:
   * Rebased on current git.

Changes V3 <- V2:
    * Style correction spotted by Andreas (virtio-scsi.h).
    * Style correction for virtio-net.h.

Changes V2 <- V1:
    * Move the dataplane include into the header (virtio-blk).
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/pixman.v8' into staging
Anthony Liguori [Mon, 18 Mar 2013 12:34:24 +0000 (07:34 -0500)]
Merge remote-tracking branch 'kraxel/pixman.v8' into staging

# By Gerd Hoffmann (18) and others
# Via Blue Swirl (1) and Gerd Hoffmann (1)
* kraxel/pixman.v8: (37 commits)
  console: remove ds_get_* helper functions
  console: zap color_table
  console: stop using DisplayState in gfx hardware emulation
  console: zap displaystate from dcl callbacks
  cocoa: stop using DisplayState
  spice: stop using DisplayState
  sdl: stop using DisplayState
  vnc: stop using DisplayState
  gtk: stop using DisplayState
  console: add surface_*() getters
  console: rework DisplaySurface handling [dcl/ui side]
  console: rework DisplaySurface handling [vga emu side]
  sdl: drop dead code
  qxl: better vga init in enter_vga_mode
  qxl: zap qxl0 global
  spice: zap sdpy global
  console: kill DisplayState->opaque
  console: fix displaychangelisteners interface
  s390: Fix cpu refactoring fallout.
  target-mips: fix rndrashift_short_acc and code for EXTR_ instructions
  ...

11 years agoconsole: remove ds_get_* helper functions
Gerd Hoffmann [Wed, 6 Mar 2013 12:40:47 +0000 (13:40 +0100)]
console: remove ds_get_* helper functions

Switch the few remaining ds_get_* uses in console.c over to the new
surface_* accessors.

While doing so tripped over a few leftovers from commit
a93a4a226a2afba147ba5df688b85d844f537c68 (code using depth == 0
as indicator for textmode rendering).  Fixed them up.

Finally dropped ds_get_* helper helpers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: zap color_table
Gerd Hoffmann [Wed, 6 Mar 2013 08:50:51 +0000 (09:50 +0100)]
console: zap color_table

qemu_create_surface hands out 32bpp surfaces.
So we can just use color_table_rgb directly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: stop using DisplayState in gfx hardware emulation
Gerd Hoffmann [Tue, 5 Mar 2013 14:24:14 +0000 (15:24 +0100)]
console: stop using DisplayState in gfx hardware emulation

Use QemuConsole instead.  Updates interfaces in console.[ch] and adapts
gfx hardware emulation code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: zap displaystate from dcl callbacks
Gerd Hoffmann [Fri, 1 Mar 2013 12:03:04 +0000 (13:03 +0100)]
console: zap displaystate from dcl callbacks

Now that nobody depends on DisplayState in DisplayChangeListener
callbacks any more we can remove the parameter from all callbacks.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agococoa: stop using DisplayState
Gerd Hoffmann [Fri, 1 Mar 2013 11:52:06 +0000 (12:52 +0100)]
cocoa: stop using DisplayState

Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agospice: stop using DisplayState
Gerd Hoffmann [Thu, 28 Feb 2013 15:42:28 +0000 (16:42 +0100)]
spice: stop using DisplayState

Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agosdl: stop using DisplayState
Gerd Hoffmann [Fri, 1 Mar 2013 08:01:13 +0000 (09:01 +0100)]
sdl: stop using DisplayState

Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agovnc: stop using DisplayState
Gerd Hoffmann [Thu, 28 Feb 2013 16:16:48 +0000 (17:16 +0100)]
vnc: stop using DisplayState

Rework DisplayStateListener callbacks to not use the DisplayState
any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agogtk: stop using DisplayState
Gerd Hoffmann [Thu, 28 Feb 2013 15:10:02 +0000 (16:10 +0100)]
gtk: stop using DisplayState

Rework DisplayStateListener callbacks to not use the DisplayState
any more.  Factor out the window size handling to a separate function,
so the zoom callbacks can call that directly instead of abusing the
gd_switch DisplayStateListener callback for that.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: add surface_*() getters
Gerd Hoffmann [Thu, 28 Feb 2013 14:24:14 +0000 (15:24 +0100)]
console: add surface_*() getters

Add convinence wrappers to query DisplaySurface properties.
Simliar to ds_get_*, but operating in the DisplaySurface
not the DisplayState.

With this patch in place ui frontents can stop using DisplayState
in the rendering code paths, they can simply operate using the
DisplaySurface passed in via dpy_gfx_switch callback.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: rework DisplaySurface handling [dcl/ui side]
Gerd Hoffmann [Thu, 28 Feb 2013 14:03:04 +0000 (15:03 +0100)]
console: rework DisplaySurface handling [dcl/ui side]

Replace the dpy_gfx_resize and dpy_gfx_setdata DisplayChangeListener
callbacks with a dpy_gfx_switch callback which notifies the ui code
when the framebuffer backing storage changes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: rework DisplaySurface handling [vga emu side]
Gerd Hoffmann [Thu, 28 Feb 2013 09:48:02 +0000 (10:48 +0100)]
console: rework DisplaySurface handling [vga emu side]

Decouple DisplaySurface allocation & deallocation from DisplayState.
Replace dpy_gfx_resize + dpy_gfx_setdata with a dpy_gfx_replace_surface
function.

This handles the graphic hardware emulation.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agosdl: drop dead code
Gerd Hoffmann [Thu, 28 Feb 2013 09:48:36 +0000 (10:48 +0100)]
sdl: drop dead code

DisplayAllocator removal (commit
187cd1d9f30d13f0d0ef682e4d91cfa3e4cbd472) made this a nop.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoqxl: better vga init in enter_vga_mode
Gerd Hoffmann [Thu, 28 Feb 2013 10:08:50 +0000 (11:08 +0100)]
qxl: better vga init in enter_vga_mode

Ask the vga core to update the display.  Will trigger dpy_gfx_resize
if needed.  More complete than just calling dpy_gfx_resize.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoqxl: zap qxl0 global
Gerd Hoffmann [Thu, 28 Feb 2013 11:15:00 +0000 (12:15 +0100)]
qxl: zap qxl0 global

DisplayChangeListener is passed now to all DisplayChangeListenerOps
callbacks, so we can use that to access the qxl state and kill the
qxl0 global variable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agospice: zap sdpy global
Gerd Hoffmann [Thu, 28 Feb 2013 13:47:07 +0000 (14:47 +0100)]
spice: zap sdpy global

DisplayChangeListener is passed now to all DisplayChangeListenerOps
callbacks, so we can use that to access the spice display state and
kill the sdpy global variable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: kill DisplayState->opaque
Gerd Hoffmann [Thu, 28 Feb 2013 10:34:31 +0000 (11:34 +0100)]
console: kill DisplayState->opaque

It's broken by design.  There can be multiple DisplayChangeListener
instances, so they simply can't store state in the (single) DisplayState
struct.  Try 'qemu -display gtk -vnc :0', watch it crash & burn.

With DisplayChangeListenerOps having a more sane interface now we can
simply use the DisplayChangeListener pointer to get access to our
private data instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoconsole: fix displaychangelisteners interface
Gerd Hoffmann [Tue, 13 Nov 2012 13:51:41 +0000 (14:51 +0100)]
console: fix displaychangelisteners interface

Split callbacks into separate Ops struct.  Pass DisplayChangeListener
pointer as first argument to all callbacks.  Uninline a bunch of
display functions and move them from console.h to console.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoSwitch to efi-enabled nic roms by default
Gerd Hoffmann [Tue, 26 Feb 2013 16:46:11 +0000 (17:46 +0100)]
Switch to efi-enabled nic roms by default

All PCI nics are switched to EFI-enabled roms by default.  They are
composed from three images (legacy, efi ia32 & efi x86), so classic
pxe booting will continue to work.

Exception: eepro100 is not switched, it uses a single rom for all
emulated eepro100 variants, then goes patch the rom header on the
fly with the correct PCI IDs.  I doubt that will work as-is with
the efi roms.

Keep old roms for 1.4+older machine types via compat properties,
needed because the efi-enabled roms are larger so the pci rom bar
size would change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoAdd efi rom binaries
Gerd Hoffmann [Mon, 4 Mar 2013 09:19:29 +0000 (10:19 +0100)]
Add efi rom binaries

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoAdd Makefile rules to build nic rom binaries with efi support
Gerd Hoffmann [Tue, 26 Feb 2013 15:45:58 +0000 (16:45 +0100)]
Add Makefile rules to build nic rom binaries with efi support

"make -C roms efirom" will build rom binaries with EFI support.
They are composed from three images: legacy bios, efi ia32
and efi x64.  So netbooting via SeaBIOS will continue to work
like it does today, and additionally we get network support
for EFI.  This target needs the EfiRom utility (shipped with
edk2) somewhere in the $PATH.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoUpdate ipxe submodule to latest master
Gerd Hoffmann [Thu, 28 Feb 2013 08:14:12 +0000 (09:14 +0100)]
Update ipxe submodule to latest master

Needed for efi support.

ipxe is grown a bit, so *not* recompiling the (non-efi) pxe roms
because that would make some pxe roms larger than 64k, which in
turn would be a guest-visible change because the rom bar size
grows from 64k to 128k.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoAdd Makefile rules to build nic rom binaries
Gerd Hoffmann [Fri, 8 Feb 2013 15:35:08 +0000 (16:35 +0100)]
Add Makefile rules to build nic rom binaries

"make -C roms pxerom" will build the ipxe roms and update
the binaries in pc-bios/, i.e. it basically documents how
the build process of our current nic roms works.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agos390: Fix cpu refactoring fallout.
Cornelia Huck [Fri, 15 Mar 2013 09:57:40 +0000 (10:57 +0100)]
s390: Fix cpu refactoring fallout.

Commit 259186a7 "cpu: Move halted and interrupt_request fields to CPUState"
seems to have missed one instance in target-s390x/kvm.c:

/home/cohuck/git/qemu/target-s390x/kvm.c: In function ‘kvm_arch_process_async_events’:
/home/cohuck/git/qemu/target-s390x/kvm.c:319: error: ‘CPUS390XState’ has no member named ‘halted’
/home/cohuck/git/qemu/target-s390x/kvm.c:320: warning: control reaches end of non-void function
make[1]: *** [target-s390x/kvm.o] Error 1

Let's just switch to cs->halted.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Alexander Graf <agraf@suse.de>
Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoMerge branch 'arm-devs.next' of git://git.linaro.org/people/pmaydell/qemu-arm
Blue Swirl [Sun, 17 Mar 2013 17:44:47 +0000 (17:44 +0000)]
Merge branch 'arm-devs.next' of git://git.linaro.org/people/pmaydell/qemu-arm

* 'arm-devs.next' of git://git.linaro.org/people/pmaydell/qemu-arm:
  xilinx_spips: QOM styling fixes
  xilinx_spips: Add missing dual-bus snoop commands
  xilinx_spips: Fix bus setup conditional check
  xilinx_spips: Set unused IRQs to NULL
  xilinx_zynq: added pl330 to machine model
  pl330: Initial version
  iov: Factor out hexdumper
  hw/vexpress: Set reset values for daughterboard oscillators
  hw/arm_sysctl: Implement SYS_CFG_OSC function
  hw/vexpress: Pass voltage sensor properties to sysctl device
  hw/arm_sysctl: Implement SYS_CFG_VOLT
  qdev: Implement (variable length) array properties
  hw/arm_sysctl: Convert from qdev init to instance_init
  hw/arm_sysctl: Implement SYS_CFG_DVIMODE as a no-op
  hw/arm_sysctl: Implement SYS_CFG_MUXFPGA writes as a no-op
  hw/arm_sysctl: Handle SYS_CFGCTRL in a more structured way
  hw/vexpress: Pass proc_id via VEDBoardInfo