Re: [Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-25 Thread Alexander Graf

On 18.02.2013, at 16:00, Erlon Cruz wrote:

 From: Erlon Cruz erlon.c...@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.c...@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
 




[Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-18 Thread Erlon Cruz
From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
---
 hw/spapr_hcall.c |   32 
 1 file changed, 32 insertions(+)

diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 2889742..80ace25 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -323,6 +323,37 @@ 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];
+target_ulong v[4], r[4];
+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 +745,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




Re: [Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-18 Thread David Gibson
On Mon, Feb 18, 2013 at 11:32:21AM -0300, Erlon Cruz wrote:
 From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
 ---
  hw/spapr_hcall.c |   32 
  1 file changed, 32 insertions(+)
 
 diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
 index 2889742..80ace25 100644
 --- a/hw/spapr_hcall.c
 +++ b/hw/spapr_hcall.c
 @@ -323,6 +323,37 @@ 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];
 +target_ulong v[4], r[4];

Uh, so, you stopped using these arrays, but the declarations are still
there.  This will cause compile failure due to -Werror with the
options qemu usually uses.

-- 
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: Digital signature


[Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-18 Thread Erlon Cruz
From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
---
 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




Re: [Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-18 Thread David Gibson
On Mon, Feb 18, 2013 at 12:00:32PM -0300, Erlon Cruz wrote:
 From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com

Acked-by: David Gibson da...@gibson.dropbear.id.au

-- 
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: Digital signature


Re: [Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-17 Thread Andreas Färber
Am 15.02.2013 11:59, schrieb Erlon Cruz:
 From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
 ---
  hw/spapr_hcall.c |   34 ++
  1 file changed, 34 insertions(+)
 
 diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
 index 2889742..1065277 100644
 --- a/hw/spapr_hcall.c
 +++ b/hw/spapr_hcall.c
 @@ -323,6 +323,39 @@ 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)

Indentation is one-off.

Andreas

 +{
 +CPUPPCState *env = cpu-env;
 +target_ulong flags = args[0];
 +target_ulong pte_index = args[1];
 +target_ulong v[4], r[4];
 +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++) {
 +v[i] = ldq_p(hpte);
 +r[i] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
 +args[ridx++] = v[i];
 +args[ridx++] = r[i];
 +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 +747,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);

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-15 Thread Erlon Cruz
From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
---
 hw/spapr_hcall.c |   34 ++
 1 file changed, 34 insertions(+)

diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 2889742..1065277 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -323,6 +323,39 @@ 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];
+target_ulong v[4], r[4];
+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++) {
+v[i] = ldq_p(hpte);
+r[i] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
+args[ridx++] = v[i];
+args[ridx++] = r[i];
+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 +747,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




Re: [Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-15 Thread Alexander Graf

On 15.02.2013, at 11:59, Erlon Cruz wrote:

 From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com

Looks good to me, but I'd like an ack from David.


Alex

 ---
 hw/spapr_hcall.c |   34 ++
 1 file changed, 34 insertions(+)
 
 diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
 index 2889742..1065277 100644
 --- a/hw/spapr_hcall.c
 +++ b/hw/spapr_hcall.c
 @@ -323,6 +323,39 @@ 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];
 +target_ulong v[4], r[4];
 +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++) {
 +v[i] = ldq_p(hpte);
 +r[i] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
 +args[ridx++] = v[i];
 +args[ridx++] = r[i];
 +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 +747,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
 




Re: [Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-12 Thread Alexander Graf

On 07.02.2013, at 12:28, Erlon Cruz wrote:

 From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
 ---
 hw/spapr_hcall.c |   58 ++
 1 file changed, 58 insertions(+)
 
 diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
 index 2889742..5ba07e5 100644
 --- a/hw/spapr_hcall.c
 +++ b/hw/spapr_hcall.c
 @@ -323,6 +323,63 @@ 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;
 +
 +if ((pte_index * HASH_PTE_SIZE_64)  ~env-htab_mask) {
 +return H_PARAMETER;
 +}
 +
 +if (!(flags  H_READ_4)) {
 +target_ulong v, r;
 +target_ulong *pteh = args[0];
 +target_ulong *ptel = args[1];
 +
 +hpte = env-external_htab + (pte_index * HASH_PTE_SIZE_64);

You are not guaranteed that there is an external htab.

In fact, looking at the external_htab users, we should probably introduce a few 
helper read functions for the htab that abstract the glorious 
external_htab/htab_base details away from you.


Alex




[Qemu-devel] [PATCH] pseries: Implements h_read hcall

2013-02-07 Thread Erlon Cruz
From: Erlon Cruz erlon.c...@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.c...@br.flextronics.com
---
 hw/spapr_hcall.c |   58 ++
 1 file changed, 58 insertions(+)

diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 2889742..5ba07e5 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -323,6 +323,63 @@ 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;
+
+if ((pte_index * HASH_PTE_SIZE_64)  ~env-htab_mask) {
+return H_PARAMETER;
+}
+
+if (!(flags  H_READ_4)) {
+target_ulong v, r;
+target_ulong *pteh = args[0];
+target_ulong *ptel = args[1];
+
+hpte = env-external_htab + (pte_index * HASH_PTE_SIZE_64);
+
+v = ldq_p(hpte);
+r = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
+
+if (flags  H_R_XLATE) {
+/* FIXME:  include a valid logical page num in the pte */
+;
+}
+
+*pteh = v;
+*ptel = r;
+
+} else {
+int i, ridx = 0;
+target_ulong v[4], r[4];
+
+/* Clear the two low order bits */
+pte_index = ~(3ULL);
+hpte = env-external_htab + (pte_index * HASH_PTE_SIZE_64);
+
+for (i = 0; i  4; i++) {
+v[i] = ldq_p(hpte);
+r[i] = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
+
+if (flags  H_R_XLATE) {
+/* FIXME:  include a valid logical page num in the pte */
+;
+}
+
+args[ridx++] = v[i];
+args[ridx++] = r[i];
+
+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 +771,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