[PATCH 5/5] s390x/pv: Move check on hugepage under s390_pv_guest_check()

Cédric Le Goater posted 5 patches 3 years, 1 month ago
Maintainers: Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>
There is a newer version of this series
[PATCH 5/5] s390x/pv: Move check on hugepage under s390_pv_guest_check()
Posted by Cédric Le Goater 3 years, 1 month ago
From: Cédric Le Goater <clg@redhat.com>

Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 hw/s390x/pv.c       | 14 +++++++++++++-
 target/s390x/diag.c |  7 -------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
index 96c0728ec9..4e1f991d98 100644
--- a/hw/s390x/pv.c
+++ b/hw/s390x/pv.c
@@ -302,9 +302,21 @@ static bool s390_pv_check_host(Error **errp)
     return true;
 }
 
+static bool s390_pv_check_hpage(Error **errp)
+{
+    if (kvm_s390_get_hpage_1m()) {
+        error_setg(errp, "Protected VMs can currently not be backed with "
+                   "huge pages");
+        return false;
+    }
+
+    return true;
+}
+
 static bool s390_pv_guest_check(const Object *obj, Error **errp)
 {
-    return s390_pv_check_cpus(errp) && s390_pv_check_host(errp);
+    return s390_pv_check_cpus(errp) && s390_pv_check_host(errp) &&
+        s390_pv_check_hpage(errp);
 }
 
 bool s390_pv_check(Error **errp)
diff --git a/target/s390x/diag.c b/target/s390x/diag.c
index 9b16e25930..28f4350aed 100644
--- a/target/s390x/diag.c
+++ b/target/s390x/diag.c
@@ -170,13 +170,6 @@ out:
             return;
         }
 
-        if (kvm_enabled() && 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;
-        }
-
         if (!s390_pv_check(&local_err)) {
             error_report_err(local_err);
             env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;
-- 
2.38.1


Re: [PATCH 5/5] s390x/pv: Move check on hugepage under s390_pv_guest_check()
Posted by Thomas Huth 3 years, 1 month ago
On 04/01/2023 12.51, Cédric Le Goater wrote:
> From: Cédric Le Goater <clg@redhat.com>
> 
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
>   hw/s390x/pv.c       | 14 +++++++++++++-
>   target/s390x/diag.c |  7 -------
>   2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
> index 96c0728ec9..4e1f991d98 100644
> --- a/hw/s390x/pv.c
> +++ b/hw/s390x/pv.c
> @@ -302,9 +302,21 @@ static bool s390_pv_check_host(Error **errp)
>       return true;
>   }
>   
> +static bool s390_pv_check_hpage(Error **errp)
> +{
> +    if (kvm_s390_get_hpage_1m()) {
> +        error_setg(errp, "Protected VMs can currently not be backed with "
> +                   "huge pages");
> +        return false;
> +    }
> +
> +    return true;
> +}
> +
>   static bool s390_pv_guest_check(const Object *obj, Error **errp)
>   {
> -    return s390_pv_check_cpus(errp) && s390_pv_check_host(errp);
> +    return s390_pv_check_cpus(errp) && s390_pv_check_host(errp) &&
> +        s390_pv_check_hpage(errp);
>   }
>   
>   bool s390_pv_check(Error **errp)
> diff --git a/target/s390x/diag.c b/target/s390x/diag.c
> index 9b16e25930..28f4350aed 100644
> --- a/target/s390x/diag.c
> +++ b/target/s390x/diag.c
> @@ -170,13 +170,6 @@ out:
>               return;
>           }
>   
> -        if (kvm_enabled() && 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;
> -        }
> -
>           if (!s390_pv_check(&local_err)) {
>               error_report_err(local_err);
>               env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;

Reviewed-by: Thomas Huth <thuth@redhat.com>