qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Janosch Frank <frankja@linux.ibm.com>, qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, cohuck@redhat.com, david@redhat.com
Subject: Re: [PATCH v9] s390x: protvirt: Fence huge pages
Date: Mon, 16 Mar 2020 17:33:47 +0100	[thread overview]
Message-ID: <03788698-c7f8-314d-d34a-54bdc372b3e7@de.ibm.com> (raw)
In-Reply-To: <0cf5c31d-0b7a-ea39-287d-7014845e765f@linux.ibm.com>



On 16.03.20 11:06, Janosch Frank wrote:
> On 3/13/20 9:21 AM, Christian Borntraeger wrote:
>>
>>
>> On 12.03.20 17:25, Janosch Frank wrote:
>>> Let's bail out of the protected transition if we detect that huge
>>> pages might be in use.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>
>>> I'd like to squash this into the unpack patch to give a proper error
>>> message if we try to transition into the protected mode while being
>>> backed by huge pages. 
>>
>> Looks good.
>> But maybe we can do it better. Why not reverse the logic and
>> instead of having kvm_s390_get_hpage_1m, let us define an protvirt_allowed
>> that as of today only returns hugepages != 1:
>> Then we could (for kvm-stub.c) also say protvirt_allowed=false;
>> And if other reasons come along we can extend.
>>
>> We could also keep this patch separate, does not really matter.
> 
> The *_allowed() functions are all based on the machine and part of
> s390-virtio-ccw.c so having one in kvm.c looks strange.
> 
> !protvirt_allowed could have any number of reasons in the future, I
> introduced this patch to give a specific error message that can help the
> user to chose the right options when looking for the error.
> 
> Other ideas or a revised one?

I am fine with either variant. If a future machine ever supports protected
guests backed by large pages we can refactor again. In the mean time the kernel
will also return with an error (I think EFAULT on the initial unpack) so this
extra check is just a mean to improve usability. So if you prefer this variant
its fine with me. 

Christian

> 
>>
>>>
>>> ---
>>>  hw/s390x/ipl.h             | 16 ++++++++++++++++
>>>  hw/s390x/s390-virtio-ccw.c |  1 -
>>>  target/s390x/diag.c        | 23 ++++++++---------------
>>>  target/s390x/kvm-stub.c    |  5 +++++
>>>  target/s390x/kvm.c         |  5 +++++
>>>  target/s390x/kvm_s390x.h   |  1 +
>>>  6 files changed, 35 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
>>> index af5bb130a6334821..95e3183c9cccf8b6 100644
>>> --- a/hw/s390x/ipl.h
>>> +++ b/hw/s390x/ipl.h
>>> @@ -185,6 +185,22 @@ struct S390IPLState {
>>>  typedef struct S390IPLState S390IPLState;
>>>  QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "alignment of iplb wrong");
>>>  
>>> +#define DIAG_308_RC_OK              0x0001
>>> +#define DIAG_308_RC_NO_CONF         0x0102
>>> +#define DIAG_308_RC_INVALID         0x0402
>>> +#define DIAG_308_RC_NO_PV_CONF      0x0902
>>> +#define DIAG_308_RC_INVAL_FOR_PV    0x0a02
>>> +
>>> +#define DIAG308_RESET_MOD_CLR       0
>>> +#define DIAG308_RESET_LOAD_NORM     1
>>> +#define DIAG308_LOAD_CLEAR          3
>>> +#define DIAG308_LOAD_NORMAL_DUMP    4
>>> +#define DIAG308_SET                 5
>>> +#define DIAG308_STORE               6
>>> +#define DIAG308_PV_SET              8
>>> +#define DIAG308_PV_STORE            9
>>> +#define DIAG308_PV_START            10
>>> +
>>>  #define S390_IPL_TYPE_FCP 0x00
>>>  #define S390_IPL_TYPE_CCW 0x02
>>>  #define S390_IPL_TYPE_PV 0x05
>>> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
>>> index ebdaaa3a001f6e8c..d32f35c7f47b9c1d 100644
>>> --- a/hw/s390x/s390-virtio-ccw.c
>>> +++ b/hw/s390x/s390-virtio-ccw.c
>>> @@ -361,7 +361,6 @@ out_err:
>>>      return rc;
>>>  }
>>>  
>>> -#define DIAG_308_RC_INVAL_FOR_PV    0x0a02
>>>  static void s390_machine_inject_pv_error(CPUState *cs)
>>>  {
>>>      int r1 = (cs->kvm_run->s390_sieic.ipa & 0x00f0) >> 4;
>>> diff --git a/target/s390x/diag.c b/target/s390x/diag.c
>>> index b245e557037ded06..b1ca81633b83bbdc 100644
>>> --- a/target/s390x/diag.c
>>> +++ b/target/s390x/diag.c
>>> @@ -21,6 +21,7 @@
>>>  #include "hw/s390x/ipl.h"
>>>  #include "hw/s390x/s390-virtio-ccw.h"
>>>  #include "hw/s390x/pv.h"
>>> +#include "kvm_s390x.h"
>>>  
>>>  int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3)
>>>  {
>>> @@ -50,21 +51,6 @@ int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3)
>>>      return diag288_class->handle_timer(diag288, func, timeout);
>>>  }
>>>  
>>> -#define DIAG_308_RC_OK              0x0001
>>> -#define DIAG_308_RC_NO_CONF         0x0102
>>> -#define DIAG_308_RC_INVALID         0x0402
>>> -#define DIAG_308_RC_NO_PV_CONF      0x0902
>>> -
>>> -#define DIAG308_RESET_MOD_CLR       0
>>> -#define DIAG308_RESET_LOAD_NORM     1
>>> -#define DIAG308_LOAD_CLEAR          3
>>> -#define DIAG308_LOAD_NORMAL_DUMP    4
>>> -#define DIAG308_SET                 5
>>> -#define DIAG308_STORE               6
>>> -#define DIAG308_PV_SET              8
>>> -#define DIAG308_PV_STORE            9
>>> -#define DIAG308_PV_START            10
>>> -
>>>  static int diag308_parm_check(CPUS390XState *env, uint64_t r1, uint64_t addr,
>>>                                uintptr_t ra, bool write)
>>>  {
>>> @@ -166,6 +152,13 @@ out:
>>>              return;
>>>          }
>>>  
>>> +        if (kvm_s390_get_hpage_1m()) {
>>> +            error_report("Protected VMs can currently not be backed with "
>>> +                         "huge pages");
>>> +            env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;
>>> +            return;
>>> +        }
>>> +
>>>          s390_ipl_reset_request(cs, S390_RESET_PV);
>>>          break;
>>>      default:
>>> diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c
>>> index c4cd497f850eb9c7..aa185017a2a886ca 100644
>>> --- a/target/s390x/kvm-stub.c
>>> +++ b/target/s390x/kvm-stub.c
>>> @@ -39,6 +39,11 @@ int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
>>>      return 0;
>>>  }
>>>  
>>> +int kvm_s390_get_hpage_1m(void)
>>> +{
>>> +    return 0;
>>> +}
>>> +
>>>  int kvm_s390_get_ri(void)
>>>  {
>>>      return 0;
>>> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
>>> index 1d6fd6a27b48e35f..c695941076b7aead 100644
>>> --- a/target/s390x/kvm.c
>>> +++ b/target/s390x/kvm.c
>>> @@ -321,6 +321,11 @@ void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp)
>>>      cap_hpage_1m = 1;
>>>  }
>>>  
>>> +int kvm_s390_get_hpage_1m(void)
>>> +{
>>> +    return cap_hpage_1m;
>>> +}
>>> +
>>>  static void ccw_machine_class_foreach(ObjectClass *oc, void *opaque)
>>>  {
>>>      MachineClass *mc = MACHINE_CLASS(oc);
>>> diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h
>>> index 0b21789796d7c462..dea813f450153c34 100644
>>> --- a/target/s390x/kvm_s390x.h
>>> +++ b/target/s390x/kvm_s390x.h
>>> @@ -23,6 +23,7 @@ void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code);
>>>  int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
>>>  void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
>>>  int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu);
>>> +int kvm_s390_get_hpage_1m(void);
>>>  int kvm_s390_get_ri(void);
>>>  int kvm_s390_get_gs(void);
>>>  int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>
>>
>>
> 
> 



  reply	other threads:[~2020-03-16 17:51 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 13:21 [PATCH v9 00/15] s390x: Protected Virtualization support Janosch Frank
2020-03-11 13:21 ` [PATCH v9 01/15] Sync pv Janosch Frank
2020-03-11 13:21 ` [PATCH v9 02/15] s390x: protvirt: Support unpack facility Janosch Frank
2020-03-12  8:33   ` Christian Borntraeger
2020-03-13  9:35     ` Janosch Frank
2020-03-13  9:52     ` [PATCH v9] fixup! Fix subcode/pbt Janosch Frank
2020-03-13 14:30       ` Christian Borntraeger
2020-03-13 14:44         ` Janosch Frank
2020-03-16 14:27       ` Cornelia Huck
2020-03-16 14:47         ` Janosch Frank
2020-03-16 14:54           ` Cornelia Huck
2020-03-16 15:04             ` Christian Borntraeger
2020-03-16 17:57               ` Cornelia Huck
2020-03-16 19:42                 ` Christian Borntraeger
2020-03-17  9:53                   ` Cornelia Huck
2020-03-16 15:05             ` Janosch Frank
2020-03-16 17:58               ` Cornelia Huck
     [not found]   ` <a0edb6d5-284f-5f10-02e5-d2f252043d71@redhat.com>
2020-03-12  8:54     ` [PATCH v9 02/15] s390x: protvirt: Support unpack facility Janosch Frank
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-11 13:21 ` [PATCH v9 03/15] s390x: protvirt: Add migration blocker Janosch Frank
2020-03-12  8:42   ` Christian Borntraeger
2020-03-12  9:34     ` Janosch Frank
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-16 14:49   ` Cornelia Huck
2020-03-11 13:21 ` [PATCH v9 04/15] s390x: protvirt: Inhibit balloon when switching to protected mode Janosch Frank
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-18 11:42   ` Cornelia Huck
2020-03-18 12:30     ` Janosch Frank
2020-03-11 13:21 ` [PATCH v9 05/15] s390x: protvirt: KVM intercept changes Janosch Frank
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-17  9:56   ` Cornelia Huck
2020-03-11 13:21 ` [PATCH v9 06/15] s390x: Add SIDA memory ops Janosch Frank
2020-03-12  8:50   ` Christian Borntraeger
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-17 10:24   ` Cornelia Huck
2020-03-17 11:56     ` Janosch Frank
2020-03-11 13:21 ` [PATCH v9 07/15] s390x: protvirt: Move STSI data over SIDAD Janosch Frank
2020-03-12 10:42   ` Christian Borntraeger
2020-03-12 11:20     ` Janosch Frank
2020-03-17 10:28       ` Cornelia Huck
2020-03-17 10:32         ` Janosch Frank
2020-03-17 10:41           ` Cornelia Huck
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-11 13:21 ` [PATCH v9 08/15] s390x: protvirt: SCLP interpretation Janosch Frank
2020-03-11 13:24   ` David Hildenbrand
2020-03-11 13:31     ` Janosch Frank
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-13 13:14   ` Christian Borntraeger
2020-03-17 11:05     ` Cornelia Huck
2020-03-17 11:54       ` Janosch Frank
2020-03-17 12:01         ` Cornelia Huck
2020-03-11 13:21 ` [PATCH v9 09/15] s390x: protvirt: Set guest IPL PSW Janosch Frank
2020-03-12 15:08   ` Christian Borntraeger
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-13 14:21     ` Janosch Frank
2020-03-13 14:22       ` Christian Borntraeger
2020-03-13 14:29       ` Claudio Imbrenda
2020-03-13 14:32       ` Claudio Imbrenda
2020-03-11 13:21 ` [PATCH v9 10/15] s390x: protvirt: Move diag 308 data over SIDA Janosch Frank
2020-03-12 15:17   ` Christian Borntraeger
2020-03-12 16:05     ` Janosch Frank
2020-03-12 16:09       ` Christian Borntraeger
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-11 13:21 ` [PATCH v9 11/15] s390x: protvirt: Disable address checks for PV guest IO emulation Janosch Frank
2020-03-12 15:41   ` Christian Borntraeger
2020-03-12 16:07     ` Janosch Frank
2020-03-12 16:10       ` Christian Borntraeger
2020-03-12 16:17         ` Janosch Frank
2020-03-13  7:38           ` Christian Borntraeger
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-17 11:36   ` Cornelia Huck
2020-03-17 12:00     ` Janosch Frank
2020-03-11 13:21 ` [PATCH v9 12/15] s390x: protvirt: Move IO control structures over SIDA Janosch Frank
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-13 13:15     ` Janosch Frank
2020-03-11 13:21 ` [PATCH v9 13/15] s390x: protvirt: Handle SIGP store status correctly Janosch Frank
2020-03-12 15:51   ` Christian Borntraeger
2020-03-12 16:13     ` Janosch Frank
2020-03-13  7:39       ` Christian Borntraeger
2020-03-13  7:39       ` Christian Borntraeger
2020-03-17 16:48       ` Cornelia Huck
2020-03-13 12:57   ` Claudio Imbrenda
2020-03-11 13:21 ` [PATCH v9 14/15] docs: Add protvirt docs Janosch Frank
     [not found]   ` <569575c9-5819-f890-e218-99f3a23bee99@redhat.com>
2020-03-12 12:10     ` Janosch Frank
2020-03-13 13:00   ` Claudio Imbrenda
2020-03-13 13:18     ` Janosch Frank
2020-03-13 13:28   ` Peter Maydell
2020-03-17 18:23     ` Cornelia Huck
2020-03-18  8:41       ` Janosch Frank
2020-03-18 11:25   ` Cornelia Huck
2020-03-18 12:34     ` Janosch Frank
2020-03-11 13:21 ` [PATCH v9 15/15] s390x: Add unpack facility feature to GA1 Janosch Frank
2020-03-13 13:01   ` Claudio Imbrenda
2020-03-17 18:06   ` Cornelia Huck
2020-03-18  8:44     ` Janosch Frank
2020-03-18  9:27       ` Cornelia Huck
2020-03-18  9:42         ` Janosch Frank
2020-03-11 14:15 ` [PATCH v9 00/15] s390x: Protected Virtualization support no-reply
2020-03-11 14:36 ` no-reply
2020-03-12 16:25 ` [PATCH v9] s390x: protvirt: Fence huge pages Janosch Frank
2020-03-13  8:21   ` Christian Borntraeger
2020-03-16 10:06     ` Janosch Frank
2020-03-16 16:33       ` Christian Borntraeger [this message]
2020-03-17 16:57   ` 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=03788698-c7f8-314d-d34a-54bdc372b3e7@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.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).