diff mbox

pseries: Implements h_read hcall

Message ID 1361199632-19727-1-git-send-email-erlon.cruz@fit-tecnologia.org.br
State New
Headers show

Commit Message

Erlon Cruz Feb. 18, 2013, 3 p.m. UTC
From: Erlon Cruz <erlon.cruz@br.flextronics.com>

This h_call is useful for DLPAR in future amongst other things. Given an index
it fetches the corresponding PTE stored in the htab.

Signed-off-by: Erlon Cruz <erlon.cruz@br.flextronics.com>
---
 hw/spapr_hcall.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

David Gibson Feb. 18, 2013, 3:02 p.m. UTC | #1
On Mon, Feb 18, 2013 at 12:00:32PM -0300, Erlon Cruz wrote:
> From: Erlon Cruz <erlon.cruz@br.flextronics.com>
> 
> This h_call is useful for DLPAR in future amongst other things. Given an index
> it fetches the corresponding PTE stored in the htab.
> 
> Signed-off-by: Erlon Cruz <erlon.cruz@br.flextronics.com>

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Alexander Graf Feb. 25, 2013, 11:23 a.m. UTC | #2
On 18.02.2013, at 16:00, Erlon Cruz wrote:

> From: Erlon Cruz <erlon.cruz@br.flextronics.com>
> 
> This h_call is useful for DLPAR in future amongst other things. Given an index
> it fetches the corresponding PTE stored in the htab.
> 
> Signed-off-by: Erlon Cruz <erlon.cruz@br.flextronics.com>

Thanks, applied to ppc-next.


Alex

> ---
> hw/spapr_hcall.c |   31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
> 
> diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
> index 2889742..56394a1 100644
> --- a/hw/spapr_hcall.c
> +++ b/hw/spapr_hcall.c
> @@ -323,6 +323,36 @@ static target_ulong h_protect(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>     return H_SUCCESS;
> }
> 
> +static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr,
> +                           target_ulong opcode, target_ulong *args)
> +{
> +    CPUPPCState *env = &cpu->env;
> +    target_ulong flags = args[0];
> +    target_ulong pte_index = args[1];
> +    uint8_t *hpte;
> +    int i, ridx, n_entries = 1;
> +
> +    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
> +        return H_PARAMETER;
> +    }
> +
> +    if (flags & H_READ_4) {
> +        /* Clear the two low order bits */
> +        pte_index &= ~(3ULL);
> +        n_entries = 4;
> +    }
> +
> +    hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
> +
> +    for (i = 0, ridx = 0; i < n_entries; i++) {
> +        args[ridx++] = ldq_p(hpte);
> +        args[ridx++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
> +        hpte += HASH_PTE_SIZE_64;
> +    }
> +
> +    return H_SUCCESS;
> +}
> +
> static target_ulong h_set_dabr(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>                                target_ulong opcode, target_ulong *args)
> {
> @@ -714,6 +744,7 @@ static void hypercall_register_types(void)
>     spapr_register_hypercall(H_ENTER, h_enter);
>     spapr_register_hypercall(H_REMOVE, h_remove);
>     spapr_register_hypercall(H_PROTECT, h_protect);
> +    spapr_register_hypercall(H_READ, h_read);
> 
>     /* hcall-bulk */
>     spapr_register_hypercall(H_BULK_REMOVE, h_bulk_remove);
> -- 
> 1.7.9.5
>
diff mbox

Patch

diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 2889742..56394a1 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -323,6 +323,36 @@  static target_ulong h_protect(PowerPCCPU *cpu, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
+static target_ulong h_read(PowerPCCPU *cpu, sPAPREnvironment *spapr,
+                           target_ulong opcode, target_ulong *args)
+{
+    CPUPPCState *env = &cpu->env;
+    target_ulong flags = args[0];
+    target_ulong pte_index = args[1];
+    uint8_t *hpte;
+    int i, ridx, n_entries = 1;
+
+    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
+        return H_PARAMETER;
+    }
+
+    if (flags & H_READ_4) {
+        /* Clear the two low order bits */
+        pte_index &= ~(3ULL);
+        n_entries = 4;
+    }
+
+    hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
+
+    for (i = 0, ridx = 0; i < n_entries; i++) {
+        args[ridx++] = ldq_p(hpte);
+        args[ridx++] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
+        hpte += HASH_PTE_SIZE_64;
+    }
+
+    return H_SUCCESS;
+}
+
 static target_ulong h_set_dabr(PowerPCCPU *cpu, sPAPREnvironment *spapr,
                                target_ulong opcode, target_ulong *args)
 {
@@ -714,6 +744,7 @@  static void hypercall_register_types(void)
     spapr_register_hypercall(H_ENTER, h_enter);
     spapr_register_hypercall(H_REMOVE, h_remove);
     spapr_register_hypercall(H_PROTECT, h_protect);
+    spapr_register_hypercall(H_READ, h_read);
 
     /* hcall-bulk */
     spapr_register_hypercall(H_BULK_REMOVE, h_bulk_remove);