[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MINI-OS PATCH v2 2/2] x86: don't use a memory page for mapping the shared info page


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jürgen Groß <jgross@xxxxxxxx>
  • Date: Tue, 29 Jul 2025 11:13:13 +0200
  • Autocrypt: addr=jgross@xxxxxxxx; keydata= xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOB ycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJve dYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJ NwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvx XP3FAp2pkW0xqG7/377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEB AAHNH0p1ZXJnZW4gR3Jvc3MgPGpncm9zc0BzdXNlLmNvbT7CwHkEEwECACMFAlOMcK8CGwMH CwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRCw3p3WKL8TL8eZB/9G0juS/kDY9LhEXseh mE9U+iA1VsLhgDqVbsOtZ/S14LRFHczNd/Lqkn7souCSoyWsBs3/wO+OjPvxf7m+Ef+sMtr0 G5lCWEWa9wa0IXx5HRPW/ScL+e4AVUbL7rurYMfwCzco+7TfjhMEOkC+va5gzi1KrErgNRHH kg3PhlnRY0Udyqx++UYkAsN4TQuEhNN32MvN0Np3WlBJOgKcuXpIElmMM5f1BBzJSKBkW0Jc Wy3h2Wy912vHKpPV/Xv7ZwVJ27v7KcuZcErtptDevAljxJtE7aJG6WiBzm+v9EswyWxwMCIO RoVBYuiocc51872tRGywc03xaQydB+9R7BHPzsBNBFOMcBYBCADLMfoA44MwGOB9YT1V4KCy vAfd7E0BTfaAurbG+Olacciz3yd09QOmejFZC6AnoykydyvTFLAWYcSCdISMr88COmmCbJzn sHAogjexXiif6ANUUlHpjxlHCCcELmZUzomNDnEOTxZFeWMTFF9Rf2k2F0Tl4E5kmsNGgtSa aMO0rNZoOEiD/7UfPP3dfh8JCQ1VtUUsQtT1sxos8Eb/HmriJhnaTZ7Hp3jtgTVkV0ybpgFg w6WMaRkrBh17mV0z2ajjmabB7SJxcouSkR0hcpNl4oM74d2/VqoW4BxxxOD1FcNCObCELfIS auZx+XT6s+CE7Qi/c44ibBMR7hyjdzWbABEBAAHCwF8EGAECAAkFAlOMcBYCGwwACgkQsN6d 1ii/Ey9D+Af/WFr3q+bg/8v5tCknCtn92d5lyYTBNt7xgWzDZX8G6/pngzKyWfedArllp0Pn fgIXtMNV+3t8Li1Tg843EXkP7+2+CQ98MB8XvvPLYAfW8nNDV85TyVgWlldNcgdv7nn1Sq8g HwB2BHdIAkYce3hEoDQXt/mKlgEGsLpzJcnLKimtPXQQy9TxUaLBe9PInPd+Ohix0XOlY+Uk QFEx50Ki3rSDl2Zt2tnkNYKUCvTJq7jvOlaPd6d/W0tZqpyy7KVay+K4aMobDsodB3dvEAs6 ScCnh03dDAFgIq5nsB11j3KPKdVoPlfucX2c7kGNH+LUMbzqV6beIENfNexkOfxHfw==
  • Cc: samuel.thibault@xxxxxxxxxxxx, minios-devel@xxxxxxxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 29 Jul 2025 09:13:19 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

On 29.07.25 11:00, Jan Beulich wrote:
On 29.07.2025 10:38, Juergen Gross wrote:
--- a/arch/x86/x86_64.S
+++ b/arch/x86/x86_64.S
@@ -33,13 +33,8 @@ _start:
  stack_start:
          .quad stack+(2*__STACK_SIZE)
-.globl shared_info, hypercall_page
-        /* Unpleasant -- the PTE that maps this page is actually overwritten */
-        /* to map the real shared-info page! :-)                             */
          .align __PAGE_SIZE
-shared_info:
-        .fill __PAGE_SIZE,1,0
-
+.globl hypercall_page

While touching this line, may I suggest to indent this directive to match all
other directives in context? Even if assemblers accept them for most targets,
directives starting in the first column strictly speaking are misplaced.

--- a/hypervisor.c
+++ b/hypervisor.c
@@ -27,8 +27,10 @@
#include <mini-os/os.h>
  #include <mini-os/lib.h>
+#include <mini-os/e820.h>
  #include <mini-os/hypervisor.h>
  #include <mini-os/events.h>
+#include <mini-os/mm.h>
  #include <xen/memory.h>
EXPORT_SYMBOL(hypercall_page);
@@ -37,7 +39,8 @@ EXPORT_SYMBOL(hypercall_page);
      ((sh)->evtchn_pending[idx] & ~(sh)->evtchn_mask[idx])
#ifndef CONFIG_PARAVIRT
-extern shared_info_t shared_info;
+static unsigned long shinfo_pfn;
+static unsigned long shinfo_va;
int hvm_get_parameter(int idx, uint64_t *value)
  {
@@ -69,24 +72,31 @@ shared_info_t *map_shared_info(void)
  {
      struct xen_add_to_physmap xatp;
+ shinfo_pfn = e820_get_reserved_pfns(1);
      xatp.domid = DOMID_SELF;
      xatp.idx = 0;
      xatp.space = XENMAPSPACE_shared_info;
-    xatp.gpfn = virt_to_pfn(&shared_info);
+    xatp.gpfn = shinfo_pfn;
      if ( HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp) != 0 )
          BUG();
+    if ( !shinfo_va )
+        shinfo_va = alloc_virt_kernel(1);
+    if ( !shinfo_va || map_frame_rw(shinfo_va, shinfo_pfn) )
+        BUG();

Now there's a new asymmetry: Here you check whether alloc_virt_kernel()
(appears to have) failed, whereas in the PV variant you don't. And it's
really only "appears to", as the function won't return 0 in the failure
case, afaics. I therefore think that extra condition simply wants
dropping here. Then

Oh, right. First I had

if ( !shinfo_va )
    shinfo_va = map_frame_virt(shinfo_pfn);
else
    ret = map_frame_rw(shinfo_va, shinfo_pfn);
if ( ret || !shinfo_va )
    BUG();

which I then simplified to above sequence, but without dropping the test for
shinfo_va being not 0.

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

As for the other patch, happy to make both adjustments while committing.
As long as you agree, of course.

Yes, I agree, thanks.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.