From: Christian Borntraeger <borntraeger@de.ibm.com>
To: David Hildenbrand <david@redhat.com>,
Janosch Frank <frankja@linux.vnet.ibm.com>
Cc: KVM <kvm@vger.kernel.org>, Cornelia Huck <cohuck@redhat.com>,
Thomas Huth <thuth@redhat.com>,
Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [RFCv2 22/37] KVM: s390: protvirt: handle secure guest prefix pages
Date: Wed, 5 Feb 2020 20:38:32 +0100 [thread overview]
Message-ID: <926e038e-4662-3b5c-4c58-f8724271290c@de.ibm.com> (raw)
In-Reply-To: <8ccf2009-d391-d91b-3088-49e950b94674@redhat.com>
On 05.02.20 12:51, David Hildenbrand wrote:
> On 03.02.20 14:19, Christian Borntraeger wrote:
>> From: Janosch Frank <frankja@linux.ibm.com>
>>
>> The SPX instruction is handled by the ulravisor. We do get a
>> notification intercept, though. Let us update our internal view.
>>
>> In addition to that, when the guest prefix page is not secure, an
>> intercept 112 (0x70) is indicated. To avoid this for the most common
>> cases, we can make the guest prefix page protected whenever we pin it.
>> We have to deal with 112 nevertheless, e.g. when some host code triggers
>> an export (e.g. qemu dump guest memory). We can simply re-run the
>> pinning logic by doing a no-op prefix change.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>> arch/s390/include/asm/kvm_host.h | 1 +
>> arch/s390/kvm/intercept.c | 15 +++++++++++++++
>> arch/s390/kvm/kvm-s390.c | 14 ++++++++++++++
>> 3 files changed, 30 insertions(+)
>>
>> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
>> index 48f382680755..686b00ced55b 100644
>> --- a/arch/s390/include/asm/kvm_host.h
>> +++ b/arch/s390/include/asm/kvm_host.h
>> @@ -225,6 +225,7 @@ struct kvm_s390_sie_block {
>> #define ICPT_PV_INT_EN 0x64
>> #define ICPT_PV_INSTR 0x68
>> #define ICPT_PV_NOTIF 0x6c
>> +#define ICPT_PV_PREF 0x70
>> __u8 icptcode; /* 0x0050 */
>> __u8 icptstatus; /* 0x0051 */
>> __u16 ihcpu; /* 0x0052 */
>> diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
>> index d63f9cf10360..ceba0abb1900 100644
>> --- a/arch/s390/kvm/intercept.c
>> +++ b/arch/s390/kvm/intercept.c
>> @@ -451,6 +451,15 @@ static int handle_operexc(struct kvm_vcpu *vcpu)
>> return kvm_s390_inject_program_int(vcpu, PGM_OPERATION);
>> }
>>
>> +static int handle_pv_spx(struct kvm_vcpu *vcpu)
>> +{
>> + u32 pref = *(u32 *)vcpu->arch.sie_block->sidad;
>> +
>> + kvm_s390_set_prefix(vcpu, pref);
>> + trace_kvm_s390_handle_prefix(vcpu, 1, pref);
>> + return 0;
>> +}
>> +
>> static int handle_pv_sclp(struct kvm_vcpu *vcpu)
>> {
>> struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
>> @@ -475,6 +484,8 @@ static int handle_pv_sclp(struct kvm_vcpu *vcpu)
>>
>> static int handle_pv_not(struct kvm_vcpu *vcpu)
>> {
>> + if (vcpu->arch.sie_block->ipa == 0xb210)
>> + return handle_pv_spx(vcpu);
>> if (vcpu->arch.sie_block->ipa == 0xb220)
>> return handle_pv_sclp(vcpu);
>>
>> @@ -533,6 +544,10 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
>> case ICPT_PV_NOTIF:
>> rc = handle_pv_not(vcpu);
>> break;
>> + case ICPT_PV_PREF:
>> + rc = 0;
>> + kvm_s390_set_prefix(vcpu, kvm_s390_get_prefix(vcpu));
>
> /me confused
>
> This is the "request to map prefix" case, right?
right.
>
> I'd *really* prefer to have a comment and a manual
>
> /* request to convert and pin the prefix pages again */
> kvm_make_request(KVM_REQ_MMU_RELOAD, vcpu)
I have no objection, this should also work.
Fixed.
>
> A TLB flush is IMHO not necessary, as the prefix did not change.
>
>> + break;
>> default:
>> return -EOPNOTSUPP;
>> }
>> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
>> index 76303b0f1226..6e74c7afae3a 100644
>> --- a/arch/s390/kvm/kvm-s390.c
>> +++ b/arch/s390/kvm/kvm-s390.c
>> @@ -3675,6 +3675,20 @@ static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu)
>> rc = gmap_mprotect_notify(vcpu->arch.gmap,
>> kvm_s390_get_prefix(vcpu),
>> PAGE_SIZE * 2, PROT_WRITE);
>> + if (!rc && kvm_s390_pv_is_protected(vcpu->kvm)) {
>> + do {
>> + rc = uv_convert_to_secure(
>> + vcpu->arch.gmap,
>> + kvm_s390_get_prefix(vcpu));
>> + } while (rc == -EAGAIN);
>> + WARN_ONCE(rc, "Error while importing first prefix page. rc %d", rc);
>> + do {
>> + rc = uv_convert_to_secure(
>> + vcpu->arch.gmap,
>> + kvm_s390_get_prefix(vcpu) + PAGE_SIZE);
>> + } while (rc == -EAGAIN);
>> + WARN_ONCE(rc, "Error while importing second prefix page. rc %d", rc);
>
> Maybe factor that out into a separate function (e.g., for a single page
> and call that twice).
I will wait until the memory management work is complete (we are almost there).
next prev parent reply other threads:[~2020-02-05 19:38 UTC|newest]
Thread overview: 200+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-03 13:19 [RFCv2 00/37] KVM: s390: Add support for protected VMs Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 01/37] DOCUMENTATION: protvirt: Protected virtual machine introduction Christian Borntraeger
2020-02-03 15:42 ` Cornelia Huck
2020-02-03 21:41 ` Christian Borntraeger
2020-02-04 9:19 ` Cornelia Huck
2020-02-04 9:32 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 02/37] s390/protvirt: introduce host side setup Christian Borntraeger
2020-02-03 17:12 ` Cornelia Huck
2020-02-03 22:03 ` Christian Borntraeger
2020-02-04 9:28 ` Cornelia Huck
2020-02-04 9:38 ` Christian Borntraeger
2020-02-04 9:49 ` Cornelia Huck
2020-02-04 8:40 ` Thomas Huth
2020-02-04 9:12 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 03/37] s390/protvirt: add ultravisor initialization Christian Borntraeger
2020-02-04 10:03 ` Thomas Huth
2020-02-04 10:23 ` Cornelia Huck
2020-02-04 11:22 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 04/37] mm:gup/writeback: add callbacks for inaccessible pages Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 05/37] s390/mm: provide memory management functions for protected KVM guests Christian Borntraeger
2020-02-04 10:57 ` Cornelia Huck
2020-02-04 11:48 ` Claudio Imbrenda
2020-02-04 11:56 ` Christian Borntraeger
2020-02-04 12:15 ` Cornelia Huck
2020-02-05 9:52 ` Janosch Frank
2020-02-03 13:19 ` [RFCv2 06/37] s390: add (non)secure page access exceptions handlers Christian Borntraeger
2020-02-04 10:37 ` Thomas Huth
2020-02-04 11:41 ` Claudio Imbrenda
2020-02-04 12:48 ` Thomas Huth
2020-02-04 13:08 ` Claudio Imbrenda
2020-02-04 13:22 ` Thomas Huth
2020-02-04 12:03 ` Christian Borntraeger
2020-02-04 11:18 ` Cornelia Huck
2020-02-04 12:04 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 07/37] KVM: s390: add new variants of UV CALL Christian Borntraeger
2020-02-04 12:11 ` Cornelia Huck
2020-02-04 12:30 ` Claudio Imbrenda
2020-02-04 12:34 ` Cornelia Huck
2020-02-04 13:33 ` Christian Borntraeger
2020-02-04 13:27 ` Thomas Huth
2020-02-04 13:55 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 08/37] KVM: s390: protvirt: Add initial lifecycle handling Christian Borntraeger
2020-02-04 12:13 ` David Hildenbrand
2020-02-04 12:34 ` Christian Borntraeger
2020-02-05 10:01 ` Janosch Frank
2020-02-04 16:27 ` Cornelia Huck
2020-02-04 21:13 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 09/37] KVM: s390: protvirt: Add KVM api documentation Christian Borntraeger
2020-02-04 20:19 ` Thomas Huth
2020-02-04 21:40 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 10/37] KVM: s390: protvirt: Secure memory is not mergeable Christian Borntraeger
2020-02-04 12:15 ` David Hildenbrand
2020-02-04 12:53 ` Christian Borntraeger
2020-02-04 12:54 ` David Hildenbrand
2020-02-04 13:04 ` [PATCH v2 " Christian Borntraeger
2020-02-04 13:05 ` David Hildenbrand
2020-02-03 13:19 ` [RFCv2 11/37] KVM: s390/mm: Make pages accessible before destroying the guest Christian Borntraeger
2020-02-04 20:52 ` Thomas Huth
2020-02-05 9:03 ` Christian Borntraeger
2020-02-05 10:35 ` Cornelia Huck
2020-02-05 18:29 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 12/37] KVM: s390: protvirt: Handle SE notification interceptions Christian Borntraeger
2020-02-04 12:16 ` David Hildenbrand
2020-02-04 12:23 ` Christian Borntraeger
2020-02-04 21:16 ` Thomas Huth
2020-02-04 21:46 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 13/37] KVM: s390: protvirt: Instruction emulation Christian Borntraeger
2020-02-04 12:20 ` David Hildenbrand
2020-02-04 12:29 ` Christian Borntraeger
2020-02-04 17:07 ` Cornelia Huck
2020-02-04 21:21 ` Thomas Huth
2020-02-03 13:19 ` [RFCv2 14/37] KVM: s390: protvirt: Add interruption injection controls Christian Borntraeger
2020-02-05 6:59 ` Thomas Huth
2020-02-05 8:46 ` Christian Borntraeger
2020-02-05 8:56 ` Michael Mueller
2020-02-05 8:54 ` Michael Mueller
2020-02-05 10:45 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 15/37] KVM: s390: protvirt: Implement interruption injection Christian Borntraeger
2020-02-05 9:51 ` Thomas Huth
2020-02-05 10:48 ` Christian Borntraeger
2020-02-05 11:25 ` Cornelia Huck
2020-02-05 17:49 ` Christian Borntraeger
2020-02-06 8:21 ` Cornelia Huck
2020-02-05 17:56 ` Christian Borntraeger
2020-02-05 11:31 ` Cornelia Huck
2020-02-05 11:46 ` Michael Mueller
2020-02-05 12:11 ` Cornelia Huck
2020-02-05 12:26 ` Michael Mueller
2020-02-05 18:00 ` Christian Borntraeger
2020-02-06 8:23 ` Cornelia Huck
2020-02-05 15:30 ` Michael Mueller
2020-02-03 13:19 ` [RFCv2 16/37] KVM: s390: protvirt: Add SCLP interrupt handling Christian Borntraeger
2020-02-05 12:22 ` Cornelia Huck
2020-02-05 18:14 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 17/37] KVM: s390: protvirt: Add machine-check interruption injection controls Christian Borntraeger
2020-02-05 7:06 ` Thomas Huth
2020-02-03 13:19 ` [RFCv2 18/37] KVM: s390: protvirt: Implement machine-check interruption injection Christian Borntraeger
2020-02-05 7:10 ` Thomas Huth
2020-02-05 13:47 ` Cornelia Huck
2020-02-05 18:18 ` Christian Borntraeger
2020-02-06 8:25 ` Cornelia Huck
2020-02-06 9:01 ` Christian Borntraeger
2020-02-06 9:11 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 19/37] KVM: s390: protvirt: Handle spec exception loops Christian Borntraeger
2020-02-05 13:50 ` Cornelia Huck
2020-02-05 18:21 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 20/37] KVM: s390: protvirt: Add new gprs location handling Christian Borntraeger
2020-02-05 11:18 ` Thomas Huth
2020-02-05 18:45 ` Christian Borntraeger
2020-02-05 13:52 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 21/37] KVM: S390: protvirt: Introduce instruction data area bounce buffer Christian Borntraeger
2020-02-05 11:43 ` David Hildenbrand
2020-02-06 8:43 ` Christian Borntraeger
2020-02-05 12:02 ` Thomas Huth
2020-02-05 12:16 ` Janosch Frank
2020-02-05 17:00 ` Thomas Huth
2020-02-06 9:07 ` Christian Borntraeger
2020-02-06 9:18 ` Thomas Huth
2020-02-06 9:21 ` Christian Borntraeger
2020-02-06 9:20 ` Christian Borntraeger
2020-02-06 9:32 ` Janosch Frank
2020-02-06 9:29 ` David Hildenbrand
2020-02-06 9:39 ` [RFCv2.1] " Christian Borntraeger
2020-02-06 9:54 ` David Hildenbrand
2020-02-06 10:02 ` Christian Borntraeger
2020-02-06 10:08 ` David Hildenbrand
2020-02-06 10:10 ` Christian Borntraeger
2020-02-06 12:46 ` Christian Borntraeger
2020-02-06 10:32 ` Thomas Huth
2020-02-06 11:07 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 22/37] KVM: s390: protvirt: handle secure guest prefix pages Christian Borntraeger
2020-02-05 11:51 ` David Hildenbrand
2020-02-05 19:38 ` Christian Borntraeger [this message]
2020-02-05 11:52 ` David Hildenbrand
2020-02-05 19:39 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 23/37] KVM: s390/mm: handle guest unpin events Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 24/37] KVM: s390: protvirt: Write sthyi data to instruction data area Christian Borntraeger
2020-02-05 12:09 ` Thomas Huth
2020-02-05 18:52 ` Christian Borntraeger
2020-02-05 14:27 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 25/37] KVM: s390: protvirt: STSI handling Christian Borntraeger
2020-02-05 12:13 ` Thomas Huth
2020-02-05 19:22 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 26/37] KVM: s390: protvirt: disallow one_reg Christian Borntraeger
2020-02-05 12:16 ` Thomas Huth
2020-02-05 19:25 ` Christian Borntraeger
2020-02-05 14:42 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 27/37] KVM: s390: protvirt: Only sync fmt4 registers Christian Borntraeger
2020-02-04 17:15 ` Cornelia Huck
2020-02-04 22:08 ` Christian Borntraeger
2020-02-05 16:29 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 28/37] KVM: s390: protvirt: Add program exception injection Christian Borntraeger
2020-02-05 16:38 ` Cornelia Huck
2020-02-05 19:31 ` Christian Borntraeger
2020-02-05 17:59 ` Thomas Huth
2020-02-05 19:32 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 29/37] DOCUMENTATION: protvirt: Diag 308 IPL Christian Borntraeger
2020-02-03 16:13 ` Cornelia Huck
2020-02-04 8:13 ` Christian Borntraeger
2020-02-04 9:35 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 30/37] KVM: s390: protvirt: Add diag 308 subcode 8 - 10 handling Christian Borntraeger
2020-02-04 18:51 ` Cornelia Huck
2020-02-04 22:19 ` Christian Borntraeger
2020-02-05 18:21 ` Thomas Huth
2020-02-06 10:59 ` Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 31/37] KVM: s390: protvirt: UV calls diag308 0, 1 Christian Borntraeger
2020-02-03 13:19 ` [RFCv2 32/37] KVM: s390: protvirt: Report CPU state to Ultravisor Christian Borntraeger
2020-02-06 11:12 ` Thomas Huth
2020-02-06 11:17 ` Christian Borntraeger
2020-02-06 14:29 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 33/37] KVM: s390: protvirt: Support cmd 5 operation state Christian Borntraeger
2020-02-06 11:21 ` Thomas Huth
2020-02-06 15:17 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 34/37] KVM: s390: protvirt: Add UV debug trace Christian Borntraeger
2020-02-06 9:41 ` Cornelia Huck
2020-02-07 8:05 ` Christian Borntraeger
2020-02-07 8:27 ` Cornelia Huck
2020-02-14 8:32 ` Christian Borntraeger
2020-02-14 8:53 ` Cornelia Huck
2020-02-03 13:19 ` [RFCv2 35/37] KVM: s390: protvirt: Mask PSW interrupt bits for interception 104 and 112 Christian Borntraeger
2020-02-06 10:10 ` Cornelia Huck
2020-02-06 11:11 ` Christian Borntraeger
2020-02-06 12:03 ` Thomas Huth
2020-02-03 13:19 ` [RFCv2 36/37] KVM: s390: protvirt: do not inject interrupts after start Christian Borntraeger
2020-02-06 10:13 ` Cornelia Huck
2020-02-06 14:24 ` Christian Borntraeger
2020-02-06 12:03 ` Thomas Huth
2020-02-03 13:19 ` [RFCv2 37/37] KVM: s390: protvirt: Add UV cpu reset calls Christian Borntraeger
2020-02-05 18:27 ` Thomas Huth
2020-02-05 20:24 ` Christian Borntraeger
2020-02-06 10:45 ` Cornelia Huck
2020-02-06 14:27 ` Christian Borntraeger
2020-02-06 14:39 ` David Hildenbrand
2020-02-06 15:07 ` Thomas Huth
2020-02-03 13:23 ` [RFCv2 00/37] KVM: s390: Add support for protected VMs Cornelia Huck
2020-02-03 13:32 ` Christian Borntraeger
2020-02-03 14:42 ` Cornelia Huck
2020-02-05 11:34 ` David Hildenbrand
2020-02-05 11:38 ` Christian Borntraeger
2020-02-05 11:40 ` Cornelia Huck
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=926e038e-4662-3b5c-4c58-f8724271290c@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=aarcange@redhat.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.vnet.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=thuth@redhat.com \
/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).