Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/768122/?format=api
{ "id": 768122, "url": "http://patchwork.ozlabs.org/api/1.2/patches/768122/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170529101218.GC13938@fergus.ozlabs.ibm.com/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/1.2/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<20170529101218.GC13938@fergus.ozlabs.ibm.com>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20170529101218.GC13938@fergus.ozlabs.ibm.com/", "date": "2017-05-29T10:12:18", "name": "[V3,2/2] KVM: PPC: Book3S HV: Enable guests to use large decrementer mode on POWER9", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "a057846bca9cab21b4940d55292e3349590e1866", "submitter": { "id": 67079, "url": "http://patchwork.ozlabs.org/api/1.2/people/67079/?format=api", "name": "Paul Mackerras", "email": "paulus@ozlabs.org" }, "delegate": { "id": 13, "url": "http://patchwork.ozlabs.org/api/1.2/users/13/?format=api", "username": "paulus", "first_name": "Paul", "last_name": "Mackerras", "email": "paulus@samba.org" }, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170529101218.GC13938@fergus.ozlabs.ibm.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/768122/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/768122/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org", "linuxppc-dev@ozlabs.org" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3wbszV4gDTz9s2s\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 29 May 2017 20:14:30 +1000 (AEST)", "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3wbszV3tYYzDqL4\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 29 May 2017 20:14:30 +1000 (AEST)", "from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3wbsx53ZcczDqBJ\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 29 May 2017 20:12:25 +1000 (AEST)", "by ozlabs.org (Postfix)\n\tid 3wbsx52Vn9z9s7t; Mon, 29 May 2017 20:12:25 +1000 (AEST)", "by ozlabs.org (Postfix, from userid 1003)\n\tid 3wbsx51q70z9s2s; Mon, 29 May 2017 20:12:25 +1000 (AEST)" ], "Date": "Mon, 29 May 2017 20:12:18 +1000", "From": "Paul Mackerras <paulus@ozlabs.org>", "To": "kvm@vger.kernel.org", "Subject": "[PATCH V3 2/2] KVM: PPC: Book3S HV: Enable guests to use large\n\tdecrementer mode on POWER9", "Message-ID": "<20170529101218.GC13938@fergus.ozlabs.ibm.com>", "References": "<20170529101113.GA13938@fergus.ozlabs.ibm.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "In-Reply-To": "<20170529101113.GA13938@fergus.ozlabs.ibm.com>", "User-Agent": "Mutt/1.5.24 (2015-08-30)", "X-BeenThere": "linuxppc-dev@lists.ozlabs.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>", "Cc": "linuxppc-dev@ozlabs.org, kvm-ppc@vger.kernel.org", "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org", "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>" }, "content": "This allows userspace (e.g. QEMU) to enable large decrementer mode for\nthe guest when running on a POWER9 host, by setting the LPCR_LD bit in\nthe guest LPCR value. With this, the guest exit code saves 64 bits of\nthe guest DEC value on exit. Other places that use the guest DEC\nvalue check the LPCR_LD bit in the guest LPCR value, and if it is set,\nomit the 32-bit sign extension that would otherwise be done.\n\nThis doesn't change the DEC emulation used by PR KVM because PR KVM\nis not supported on POWER9 yet.\n\nThis is partly based on an earlier patch by Oliver O'Halloran.\n\nSigned-off-by: Paul Mackerras <paulus@ozlabs.org>\n---\n arch/powerpc/include/asm/kvm_host.h | 2 +-\n arch/powerpc/kvm/book3s_hv.c | 6 ++++++\n arch/powerpc/kvm/book3s_hv_rmhandlers.S | 29 ++++++++++++++++++++++++-----\n arch/powerpc/kvm/emulate.c | 4 ++--\n 4 files changed, 33 insertions(+), 8 deletions(-)", "diff": "diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h\nindex 9c51ac4..3f879c8 100644\n--- a/arch/powerpc/include/asm/kvm_host.h\n+++ b/arch/powerpc/include/asm/kvm_host.h\n@@ -579,7 +579,7 @@ struct kvm_vcpu_arch {\n \tulong mcsrr0;\n \tulong mcsrr1;\n \tulong mcsr;\n-\tu32 dec;\n+\tulong dec;\n #ifdef CONFIG_BOOKE\n \tu32 decar;\n #endif\ndiff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c\nindex 42b7a4f..9b2eb66 100644\n--- a/arch/powerpc/kvm/book3s_hv.c\n+++ b/arch/powerpc/kvm/book3s_hv.c\n@@ -1143,6 +1143,12 @@ static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr,\n \tmask = LPCR_DPFD | LPCR_ILE | LPCR_TC;\n \tif (cpu_has_feature(CPU_FTR_ARCH_207S))\n \t\tmask |= LPCR_AIL;\n+\t/*\n+\t * On POWER9, allow userspace to enable large decrementer for the\n+\t * guest, whether or not the host has it enabled.\n+\t */\n+\tif (cpu_has_feature(CPU_FTR_ARCH_300))\n+\t\tmask |= LPCR_LD;\n \n \t/* Broken 32-bit version of LPCR must not clear top bits */\n \tif (preserve_top32)\ndiff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S\nindex e390b38..3c901b5 100644\n--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S\n+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S\n@@ -920,7 +920,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_300)\n \tmftb\tr7\n \tsubf\tr3,r7,r8\n \tmtspr\tSPRN_DEC,r3\n-\tstw\tr3,VCPU_DEC(r4)\n+\tstd\tr3,VCPU_DEC(r4)\n \n \tld\tr5, VCPU_SPRG0(r4)\n \tld\tr6, VCPU_SPRG1(r4)\n@@ -1032,7 +1032,13 @@ kvmppc_cede_reentry:\t\t/* r4 = vcpu, r13 = paca */\n \tli\tr0, BOOK3S_INTERRUPT_EXTERNAL\n \tbne\tcr1, 12f\n \tmfspr\tr0, SPRN_DEC\n-\tcmpwi\tr0, 0\n+BEGIN_FTR_SECTION\n+\t/* On POWER9 check whether the guest has large decrementer enabled */\n+\tandis.\tr8, r8, LPCR_LD@h\n+\tbne\t15f\n+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)\n+\textsw\tr0, r0\n+15:\tcmpdi\tr0, 0\n \tli\tr0, BOOK3S_INTERRUPT_DECREMENTER\n \tbge\t5f\n \n@@ -1459,12 +1465,18 @@ mc_cont:\n \tmtspr\tSPRN_SPURR,r4\n \n \t/* Save DEC */\n+\tld\tr3, HSTATE_KVM_VCORE(r13)\n \tmfspr\tr5,SPRN_DEC\n \tmftb\tr6\n+\t/* On P9, if the guest has large decr enabled, don't sign extend */\n+BEGIN_FTR_SECTION\n+\tld\tr4, VCORE_LPCR(r3)\n+\tandis.\tr4, r4, LPCR_LD@h\n+\tbne\t16f\n+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)\n \textsw\tr5,r5\n-\tadd\tr5,r5,r6\n+16:\tadd\tr5,r5,r6\n \t/* r5 is a guest timebase value here, convert to host TB */\n-\tld\tr3,HSTATE_KVM_VCORE(r13)\n \tld\tr4,VCORE_TB_OFFSET(r3)\n \tsubf\tr5,r4,r5\n \tstd\tr5,VCPU_DEC_EXPIRES(r9)\n@@ -2376,8 +2388,15 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM)\n \tmfspr\tr3, SPRN_DEC\n \tmfspr\tr4, SPRN_HDEC\n \tmftb\tr5\n+BEGIN_FTR_SECTION\n+\t/* On P9 check whether the guest has large decrementer mode enabled */\n+\tld\tr6, HSTATE_KVM_VCORE(r13)\n+\tld\tr6, VCORE_LPCR(r6)\n+\tandis.\tr6, r6, LPCR_LD@h\n+\tbne\t68f\n+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)\n \textsw\tr3, r3\n-\tEXTEND_HDEC(r4)\n+68:\tEXTEND_HDEC(r4)\n \tcmpd\tr3, r4\n \tble\t67f\n \tmtspr\tSPRN_DEC, r4\ndiff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c\nindex c873ffe..4d8b4d6 100644\n--- a/arch/powerpc/kvm/emulate.c\n+++ b/arch/powerpc/kvm/emulate.c\n@@ -39,7 +39,7 @@ void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)\n \tunsigned long dec_nsec;\n \tunsigned long long dec_time;\n \n-\tpr_debug(\"mtDEC: %x\\n\", vcpu->arch.dec);\n+\tpr_debug(\"mtDEC: %lx\\n\", vcpu->arch.dec);\n \thrtimer_try_to_cancel(&vcpu->arch.dec_timer);\n \n #ifdef CONFIG_PPC_BOOK3S\n@@ -109,7 +109,7 @@ static int kvmppc_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)\n \tcase SPRN_TBWU: break;\n \n \tcase SPRN_DEC:\n-\t\tvcpu->arch.dec = spr_val;\n+\t\tvcpu->arch.dec = (u32) spr_val;\n \t\tkvmppc_emulate_dec(vcpu);\n \t\tbreak;\n \n", "prefixes": [ "V3", "2/2" ] }