[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [RFC NO-MERGE 07/12] target/ppc: Implement H_REGISTER_PRO
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [RFC NO-MERGE 07/12] target/ppc: Implement H_REGISTER_PROCESS_TABLE H_CALL for tcg guests |
Date: |
Mon, 20 Feb 2017 12:48:48 +1100 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Fri, Feb 17, 2017 at 04:08:07PM +1100, Suraj Jitindar Singh wrote:
> The H_REGISTER_PROCESS_TABLE H_CALL is used by a guest to indicate to the
> hypervisor where in memory its process table is and how translation should
> be performed using this process table.
>
> Provide the implementation of this H_CALL for a tcg guest. If called by a
> KVM guest it will return H_FUNCTION for now with //TODO markers where code
> should be added to implement the required functionality.
>
> We first check for invalid flags, then parse the flags to determine the
> operation, and then check the other parameters for valid values based on
> the operation (register new table/deregister table/maintain registration).
> The process table is then stored in the appropriate location, and the
> LPCR_[UPRT/GTSE] bits are updated as required.
>
> Signed-off-by: Suraj Jitindar Singh <address@hidden>
> ---
> hw/ppc/spapr_hcall.c | 64
> +++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 61 insertions(+), 3 deletions(-)
>
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 7afedbd..bf80543 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -12,6 +12,7 @@
> #include "trace.h"
> #include "kvm_ppc.h"
> #include "hw/ppc/spapr_ovec.h"
> +#include "mmu.h"
>
> struct SPRSyncState {
> int spr;
> @@ -902,9 +903,66 @@ static target_ulong h_register_process_table(PowerPCCPU
> *cpu,
> target_ulong opcode,
> target_ulong *args)
> {
> - qemu_log_mask(LOG_UNIMP, "Unimplemented SPAPR hcall 0x" TARGET_FMT_lx
> "%s\n",
> - opcode, " (H_REGISTER_PROC_TBL)");
> - return H_FUNCTION;
> + CPUPPCState *env = &cpu->env;
> + target_ulong flags = args[0];
> + target_ulong proc_tbl = args[1];
> + target_ulong page_size = args[2];
> + target_ulong table_size = args[3];
> + uint64_t cproc = spapr->patb_entry; /* Get the current table */
> +
> + if (flags & ~0x1fULL) { /* Check no reserved bits are set */
Some #defines for the bit masks would be nice.
> + return H_PARAMETER;
> + } else if (!(flags & 0x10)) { /* Maintain current registration */
> + if (!!(flags & 0x4) ^ !!(cproc & PATBE1_GR)) {
> + return H_PARAMETER; /* Existing Process Table Mismatch */
> + }
> + } else if (!(flags & 0x8)) { /* Deregister current process table */
> + if (kvm_enabled()) {
> + // TODO - how does kvm handle deregistration?
> + return H_FUNCTION;
I think H_HARDWARE would be preferable.
> + } else {
> + cproc = 0x0ULL; /* Set to benign value - 0 works */
> + }
> + } else if (flags & 0x4) { /* Register new RADIX process table */
> + if (proc_tbl & 0xfff || proc_tbl >> 60) {
> + return H_P2;
> + } else if (page_size) {
> + return H_P3;
> + } else if (table_size > 24) {
> + return H_P4;
> + }
> + cproc = PATBE1_GR | proc_tbl | table_size;
> + // TODO
> + // Free HTAB if non-null
> + } else { /* Register new HPT process table */
> + if (proc_tbl >> 38) {
> + return H_P2;
> + } else if (page_size & ~0x7) {
> + return H_P3;
> + } else if (table_size > 24) {
> + return H_P4;
> + }
> + cproc = (proc_tbl << 25) | page_size << 5 | table_size;
> + }
> +
> + if (kvm_enabled()) {
> + // TODO - kvmppc_configure_v3_mmu()
> + return H_FUNCTION;
> + } else {
> + spapr->patb_entry = cproc; /* Save new process table */
> + if (flags & 0x6) { /* Partition Uses Process Tables */
> + env->spr[SPR_LPCR] |= LPCR_UPRT;
> + } else {
> + env->spr[SPR_LPCR] &= ~LPCR_UPRT;
It's probably safer to update the LPCR in the kvm case as well. In
migration we'll need the qemu copy of it - we'd probably reload it
from KVM before then, but safer to keep it in sync anyway.
> + }
> + if (flags & 0x1) { /* Partition Uses Guest Translation Shootdown */
> + env->spr[SPR_LPCR] |= LPCR_GTSE;
> + } else {
> + env->spr[SPR_LPCR] &= ~LPCR_GTSE;
> + }
> + }
> +
> + return H_SUCCESS;
> }
>
> #define H_SIGNAL_SYS_RESET_ALL -1
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
[Qemu-ppc] [RFC NO-MERGE 10/12] target/ppc: Adapt tlbie[l] for ISAv3.00 Support, Suraj Jitindar Singh, 2017/02/17
[Qemu-ppc] [RFC NO-MERGE 09/12] target/ppc: Flush TLB on write to PIDR, Suraj Jitindar Singh, 2017/02/17