From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
To: kvm-ppc@vger.kernel.org
Cc: paulus@ozlabs.org, kvm@vger.kernel.org,
Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Subject: [PATCH 23/23] KVM: PPC: Book3S HV: Add nested hpt pte information to debugfs
Date: Mon, 26 Aug 2019 16:21:09 +1000 [thread overview]
Message-ID: <20190826062109.7573-24-sjitindarsingh@gmail.com> (raw)
In-Reply-To: <20190826062109.7573-1-sjitindarsingh@gmail.com>
The radix entry in the vm debugfs folder is used to export debug
information about the ptes contained in the page table of a radix guest.
There is a corrsponding htab entry which provides the same pte
information for a hpt (hash page table) guest.
When a radix guest is running a nested guest this entry also provides
information about the shadow ptes in the shadow page table.
Add the same information for a nested hpt guest running under a radix
guest to this entry. The format followed is the same as that for the
htab entry for a hpt guest.
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
arch/powerpc/kvm/book3s_64_mmu_radix.c | 157 +++++++++++++++++++++------------
1 file changed, 101 insertions(+), 56 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index 48b844d33dc9..8ab9d487c9e8 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -1188,6 +1188,8 @@ static int debugfs_radix_release(struct inode *inode, struct file *file)
return 0;
}
+#define HPTE_SIZE (2 * sizeof(unsigned long))
+
static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
size_t len, loff_t *ppos)
{
@@ -1197,6 +1199,7 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
struct kvm *kvm;
unsigned long gpa;
pgd_t *pgt;
+ struct kvm_hpt_info *hpt;
struct kvm_nested_guest *nested;
pgd_t pgd, *pgdp;
pud_t pud, *pudp;
@@ -1234,84 +1237,126 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
gpa = p->gpa;
nested = NULL;
pgt = NULL;
+ hpt = NULL;
while (len != 0 && p->lpid >= 0) {
- if (gpa >= RADIX_PGTABLE_RANGE) {
- gpa = 0;
- pgt = NULL;
- if (nested) {
- kvmhv_put_nested(nested);
- nested = NULL;
- }
- p->lpid = kvmhv_nested_next_lpid(kvm, p->lpid);
- p->hdr = 0;
- if (p->lpid < 0)
- break;
- }
- if (!pgt) {
+ if (!pgt && !hpt) {
if (p->lpid == 0) {
pgt = kvm->arch.pgtable;
} else {
nested = kvmhv_get_nested(kvm, p->lpid, false);
if (!nested) {
- gpa = RADIX_PGTABLE_RANGE;
+ p->lpid = kvmhv_nested_next_lpid(kvm,
+ p->lpid);
continue;
}
- pgt = nested->shadow_pgtable;
+ if (nested->radix)
+ pgt = nested->shadow_pgtable;
+ else
+ hpt = &nested->shadow_hpt;
}
}
+ if ((pgt && (gpa >= RADIX_PGTABLE_RANGE)) || (hpt &&
+ (gpa >= kvmppc_hpt_npte(hpt)))) {
+ gpa = 0;
+ pgt = NULL;
+ hpt = NULL;
+ if (nested) {
+ kvmhv_put_nested(nested);
+ nested = NULL;
+ }
+ p->lpid = kvmhv_nested_next_lpid(kvm, p->lpid);
+ p->hdr = 0;
+ continue;
+ }
n = 0;
if (!p->hdr) {
if (p->lpid > 0)
n = scnprintf(p->buf, sizeof(p->buf),
- "\nNested LPID %d: ", p->lpid);
- n += scnprintf(p->buf + n, sizeof(p->buf) - n,
- "pgdir: %lx\n", (unsigned long)pgt);
+ "\nNested LPID %d: \n", p->lpid);
+ if (pgt)
+ n += scnprintf(p->buf + n, sizeof(p->buf) - n,
+ "RADIX:\npgdir: %lx\n",
+ (unsigned long)pgt);
+ else
+ n += scnprintf(p->buf + n, sizeof(p->buf) - n,
+ "HASH:\nnpte: %lx\n",
+ kvmppc_hpt_npte(hpt));
p->hdr = 1;
goto copy;
}
- pgdp = pgt + pgd_index(gpa);
- pgd = READ_ONCE(*pgdp);
- if (!(pgd_val(pgd) & _PAGE_PRESENT)) {
- gpa = (gpa & PGDIR_MASK) + PGDIR_SIZE;
- continue;
- }
+ if (pgt) {
+ pgdp = pgt + pgd_index(gpa);
+ pgd = READ_ONCE(*pgdp);
+ if (!(pgd_val(pgd) & _PAGE_PRESENT)) {
+ gpa = (gpa & PGDIR_MASK) + PGDIR_SIZE;
+ continue;
+ }
- pudp = pud_offset(&pgd, gpa);
- pud = READ_ONCE(*pudp);
- if (!(pud_val(pud) & _PAGE_PRESENT)) {
- gpa = (gpa & PUD_MASK) + PUD_SIZE;
- continue;
- }
- if (pud_val(pud) & _PAGE_PTE) {
- pte = pud_val(pud);
- shift = PUD_SHIFT;
- goto leaf;
- }
+ pudp = pud_offset(&pgd, gpa);
+ pud = READ_ONCE(*pudp);
+ if (!(pud_val(pud) & _PAGE_PRESENT)) {
+ gpa = (gpa & PUD_MASK) + PUD_SIZE;
+ continue;
+ }
+ if (pud_val(pud) & _PAGE_PTE) {
+ pte = pud_val(pud);
+ shift = PUD_SHIFT;
+ goto leaf;
+ }
- pmdp = pmd_offset(&pud, gpa);
- pmd = READ_ONCE(*pmdp);
- if (!(pmd_val(pmd) & _PAGE_PRESENT)) {
- gpa = (gpa & PMD_MASK) + PMD_SIZE;
- continue;
- }
- if (pmd_val(pmd) & _PAGE_PTE) {
- pte = pmd_val(pmd);
- shift = PMD_SHIFT;
- goto leaf;
- }
+ pmdp = pmd_offset(&pud, gpa);
+ pmd = READ_ONCE(*pmdp);
+ if (!(pmd_val(pmd) & _PAGE_PRESENT)) {
+ gpa = (gpa & PMD_MASK) + PMD_SIZE;
+ continue;
+ }
+ if (pmd_val(pmd) & _PAGE_PTE) {
+ pte = pmd_val(pmd);
+ shift = PMD_SHIFT;
+ goto leaf;
+ }
- ptep = pte_offset_kernel(&pmd, gpa);
- pte = pte_val(READ_ONCE(*ptep));
- if (!(pte & _PAGE_PRESENT)) {
- gpa += PAGE_SIZE;
- continue;
- }
- shift = PAGE_SHIFT;
- leaf:
- n = scnprintf(p->buf, sizeof(p->buf),
+ ptep = pte_offset_kernel(&pmd, gpa);
+ pte = pte_val(READ_ONCE(*ptep));
+ if (!(pte & _PAGE_PRESENT)) {
+ gpa += PAGE_SIZE;
+ continue;
+ }
+ shift = PAGE_SHIFT;
+ leaf:
+ n = scnprintf(p->buf, sizeof(p->buf),
" %lx: %lx %d\n", gpa, pte, shift);
- gpa += 1ul << shift;
+ gpa += 1ul << shift;
+ } else { /* hpt */
+ __be64 *hptp = (__be64 *)(hpt->virt + (gpa * HPTE_SIZE));
+ unsigned long v, hr, gr;
+
+ if (!(be64_to_cpu(hptp[0]) & (HPTE_V_VALID |
+ HPTE_V_ABSENT))) {
+ gpa++;
+ continue;
+ }
+ /* lock the HPTE so it's stable and read it */
+ preempt_disable();
+ while (!try_lock_hpte(hptp, HPTE_V_HVLOCK))
+ cpu_relax();
+ v = be64_to_cpu(hptp[0]) & ~HPTE_V_HVLOCK;
+ hr = be64_to_cpu(hptp[1]);
+ gr = hpt->rev[gpa].guest_rpte;
+ unlock_hpte(hptp, v);
+ preempt_enable();
+
+ if (!(v & (HPTE_V_VALID | HPTE_V_ABSENT))) {
+ gpa++;
+ continue;
+ }
+
+ n = scnprintf(p->buf, sizeof(p->buf),
+ "%6lx %.16lx %.16lx %.16lx\n",
+ gpa, v, hr, gr);
+ gpa++;
+ }
copy:
p->chars_left = n;
if (n > len)
--
2.13.6
prev parent reply other threads:[~2019-08-26 6:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 6:20 [PATCH 00/23] KVM: PPC: BOok3S HV: Support for nested HPT guests Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 01/23] KVM: PPC: Book3S HV: Use __gfn_to_pfn_memslot in HPT page fault handler Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 02/23] KVM: PPC: Book3S HV: Increment mmu_notifier_seq when modifying radix pte rc bits Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 03/23] KVM: PPC: Book3S HV: Nested: Don't allow hash guests to run nested guests Suraj Jitindar Singh
2019-10-23 4:47 ` Paul Mackerras
2019-08-26 6:20 ` [PATCH 04/23] KVM: PPC: Book3S HV: Handle making H_ENTER_NESTED hcall in a separate function Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 05/23] KVM: PPC: Book3S HV: Enable calling kvmppc_hpte_hv_fault in virtual mode Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 06/23] KVM: PPC: Book3S HV: Allow hpt manipulation hcalls to be called " Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 07/23] KVM: PPC: Book3S HV: Make kvmppc_invalidate_hpte() take lpid not a kvm struct Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 08/23] KVM: PPC: Book3S HV: Nested: Allow pseries hypervisor to run hpt nested guest Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 09/23] KVM: PPC: Book3S HV: Nested: Improve comments and naming of nest rmap functions Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 10/23] KVM: PPC: Book3S HV: Nested: Increase gpa field in nest rmap to 46 bits Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 11/23] KVM: PPC: Book3S HV: Nested: Remove single nest rmap entries Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 12/23] KVM: PPC: Book3S HV: Nested: add kvmhv_remove_all_nested_rmap_lpid() Suraj Jitindar Singh
2019-08-26 6:20 ` [PATCH 13/23] KVM: PPC: Book3S HV: Nested: Infrastructure for nested hpt guest setup Suraj Jitindar Singh
2019-10-24 3:43 ` Paul Mackerras
2019-08-26 6:21 ` [PATCH 14/23] KVM: PPC: Book3S HV: Nested: Context switch slb for nested hpt guest Suraj Jitindar Singh
2019-10-24 4:48 ` Paul Mackerras
2019-08-26 6:21 ` [PATCH 15/23] KVM: PPC: Book3S HV: Store lpcr and hdec_exp in the vcpu struct Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 16/23] KVM: PPC: Book3S HV: Nested: Make kvmppc_run_vcpu() entry path nested capable Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 17/23] KVM: PPC: Book3S HV: Nested: Rename kvmhv_xlate_addr_nested_radix Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 18/23] KVM: PPC: Book3S HV: Separate out hashing from kvmppc_hv_find_lock_hpte() Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 19/23] KVM: PPC: Book3S HV: Nested: Implement nested hpt mmu translation Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 20/23] KVM: PPC: Book3S HV: Nested: Handle tlbie hcall for nested hpt guest Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 21/23] KVM: PPC: Book3S HV: Nested: Implement nest rmap invalidations for hpt guests Suraj Jitindar Singh
2019-08-26 6:21 ` [PATCH 22/23] KVM: PPC: Book3S HV: Nested: Enable nested " Suraj Jitindar Singh
2019-08-26 6:21 ` Suraj Jitindar Singh [this message]
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=20190826062109.7573-24-sjitindarsingh@gmail.com \
--to=sjitindarsingh@gmail.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=paulus@ozlabs.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