From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
Anton Blanchard <anton@ozlabs.org>
Cc: linuxppc-dev@lists.ozlabs.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [RFC PATCH 13/17] powerpc/kvm/hash: Implement HASH_BULK_REMOVE hcall
Date: Wed, 2 Aug 2017 11:10:12 +0530 [thread overview]
Message-ID: <20170802054016.8927-14-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170802054016.8927-1-aneesh.kumar@linux.vnet.ibm.com>
This is equivalent to H_BULK_REMOVE hcall, but then takes hash value as the arg
instead of hashpte slot number. We will use this later to speed up bulk remove
operation in guest. Instead of finding slot number using H_READ4 hcall, we can
use hash value directly using this hcall.
only support H_AVPN operation
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/book3s/64/mmu-hash.h | 2 +
arch/powerpc/include/asm/hvcall.h | 3 +-
arch/powerpc/kvm/book3s_hv.c | 1 +
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 95 +++++++++++++++++++++++++++
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 1 +
5 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index a784d4ac4fb1..946d02d02822 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -68,6 +68,8 @@
*/
#define HPTES_PER_GROUP 8
+/* ISA defines max HTAB SIZE bits 46 */
+#define MAX_HTAB_MASK ((1UL << 46) - 1)
#define HPTE_V_SSIZE_SHIFT 62
#define HPTE_V_AVPN_SHIFT 7
diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h
index c234be675774..17366e5a2897 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -282,7 +282,8 @@
#define H_SIGNAL_SYS_RESET 0x380
#define H_HASH_REMOVE 0x384
#define H_HASH_PROTECT 0x388
-#define MAX_HCALL_OPCODE H_HASH_PROTECT
+#define H_HASH_BULK_REMOVE 0x38C
+#define MAX_HCALL_OPCODE H_HASH_BULK_REMOVE
/* H_VIOCTL functions */
#define H_GET_VIOA_DUMP_SIZE 0x01
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index d7be56339d53..01cfea8c684f 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4146,6 +4146,7 @@ static unsigned int default_hcall_list[] = {
#endif
H_HASH_PROTECT,
H_HASH_REMOVE,
+ H_HASH_BULK_REMOVE,
0
};
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index 2aa507614819..e6820a84daca 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -752,6 +752,101 @@ long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu)
return ret;
}
+long kvmppc_h_hash_bulk_remove(struct kvm_vcpu *vcpu)
+{
+ struct kvm *kvm = vcpu->kvm;
+ unsigned long *args = &vcpu->arch.gpr[4];
+ __be64 *hp, *hptes[4];
+ unsigned long tlbrb[4];
+ long int i, j, k, n, pte_index[4];
+ unsigned long flags, req, hash, rcbits;
+ int global;
+ long int ret = H_SUCCESS;
+ struct revmap_entry *rev, *revs[4];
+ u64 hp0, hp1;
+
+ if (kvm_is_radix(kvm))
+ return H_FUNCTION;
+
+ global = global_invalidates(kvm);
+ for (i = 0; i < 4 && ret == H_SUCCESS; ) {
+ n = 0;
+ for (; i < 4; ++i) {
+ j = i * 2;
+ hash = args[j];
+ flags = hash >> 56;
+ hash &= ((1ul << 56) - 1);
+ req = flags >> 6;
+ flags &= 3;
+ if (req == 3) { /* no more requests */
+ i = 4;
+ break;
+ }
+ /* only support avpn flag */
+ if (req != 1 || flags != 2) {
+ /* parameter error */
+ args[j] = ((0xa0 | flags) << 56) + hash;
+ ret = H_PARAMETER;
+ break;
+ }
+ /*
+ * We wait here to take lock for all hash values
+ * FIXME!! will that deadlock ?
+ */
+ hp = kvmppc_find_hpte_slot(kvm, hash,
+ args[j + 1], &pte_index[n]);
+ if (!hp) {
+ args[j] = ((0x90 | flags) << 56) + hash;
+ continue;
+ }
+ hp0 = be64_to_cpu(hp[0]);
+ hp1 = be64_to_cpu(hp[1]);
+ if (cpu_has_feature(CPU_FTR_ARCH_300)) {
+ hp0 = hpte_new_to_old_v(hp0, hp1);
+ hp1 = hpte_new_to_old_r(hp1);
+ }
+ args[j] = ((0x80 | flags) << 56) + hash;
+ rev = real_vmalloc_addr(&kvm->arch.hpt.rev[pte_index[n]]);
+ note_hpte_modification(kvm, rev);
+
+ if (!(hp0 & HPTE_V_VALID)) {
+ /* insert R and C bits from PTE */
+ rcbits = rev->guest_rpte & (HPTE_R_R|HPTE_R_C);
+ args[j] |= rcbits << (56 - 5);
+ hp[0] = 0;
+ if (is_mmio_hpte(hp0, hp1))
+ atomic64_inc(&kvm->arch.mmio_update);
+ continue;
+ }
+ /* leave it locked */
+ hp[0] &= ~cpu_to_be64(HPTE_V_VALID);
+ tlbrb[n] = compute_tlbie_rb(hp0, hp1, pte_index[n]);
+ hptes[n] = hp;
+ revs[n] = rev;
+ ++n;
+ }
+
+ if (!n)
+ break;
+
+ /* Now that we've collected a batch, do the tlbies */
+ do_tlbies(kvm, tlbrb, n, global, true);
+
+ /* Read PTE low words after tlbie to get final R/C values */
+ for (k = 0; k < n; ++k) {
+ hp = hptes[k];
+ rev = revs[k];
+ remove_revmap_chain(kvm, pte_index[k], rev,
+ be64_to_cpu(hp[0]), be64_to_cpu(hp[1]));
+ rcbits = rev->guest_rpte & (HPTE_R_R|HPTE_R_C);
+ args[j] |= rcbits << (56 - 5);
+ __unlock_hpte(hp, 0);
+ }
+ }
+
+ return ret;
+}
+
long __kvmppc_do_hash_protect(struct kvm *kvm, __be64 *hpte,
unsigned long flags, unsigned long pte_index)
{
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 3ca9c3fb3320..cc6ddf0cfa0c 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -2322,6 +2322,7 @@ hcall_real_table:
.space ((H_HASH_REMOVE - 4) - H_RANDOM), 0
.long DOTSYM(kvmppc_h_hash_remove) - hcall_real_table
.long DOTSYM(kvmppc_h_hash_protect) - hcall_real_table
+ .long DOTSYM(kvmppc_h_hash_bulk_remove) - hcall_real_table
.globl hcall_real_table_end
hcall_real_table_end:
--
2.13.3
next prev parent reply other threads:[~2017-08-02 5:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 5:39 [RFC PATCH 00/17] Remove slot tracking from linux page table Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 01/17] powerpc/mm: Update native_hpte_find to return hash pte Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 02/17] powerpc/pseries: Update hpte find helper to take hash value Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 03/17] powerpc/ps3/mm: Add helper for finding hash pte slot using " Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 04/17] powerpc/mm: Add hash invalidate callback Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 05/17] powerpc/mm: use hash_invalidate for __kernel_map_pages() Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 06/17] powerpc/mm: Switch flush_hash_range to not use slot Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 07/17] powerpc/mm: Add hash updatepp callback Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 08/17] powerpc/mm/hash: Don't track hash pte slot number in linux page table Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 09/17] powerpc/mm: Remove unused flag arg in global_invalidates Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 10/17] powerpc/mm: Add new firmware feature HASH API Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 11/17] powerpc/kvm/hash: Implement HASH_REMOVE hcall Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 12/17] powerpc/kvm/hash: Implement HASH_PROTECT hcall Aneesh Kumar K.V
2017-08-02 5:40 ` Aneesh Kumar K.V [this message]
2017-08-02 5:40 ` [RFC PATCH 14/17] powerpc/mm/pseries: Use HASH_PROTECT hcall in guest Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 15/17] powerpc/mm/pseries: Use HASH_REMOVE " Aneesh Kumar K.V
2017-08-02 5:40 ` [RFC PATCH 16/17] powerpc/mm/pseries: Move slot based bulk remove to helper Aneesh Kumar K.V
2017-08-02 12:50 ` Segher Boessenkool
2017-08-02 5:40 ` [RFC PATCH 17/17] powerpc/mm/pseries: Use HASH_BULK_REMOVE hcall in guest Aneesh Kumar K.V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170802054016.8927-14-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=anton@ozlabs.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).