qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* CVMSEG Emulation
@ 2022-12-08 15:08 Christopher Wrogg
  2022-12-08 21:54 ` Jiaxun Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Wrogg @ 2022-12-08 15:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Jiaxun Yang, Aleksandar Rikalo, Aurelien Jarno,
	Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

<https://matrix.to/#/!xtcopKjjucUQThGiEn:matrix.org/$16705104253940lCHrT:matrix.org?via=matrix.org&via=matrix.im&via=matrix.alindner.org>
In userspace emulation how do I make a set of addresses always valid and
initialized to 0 even though the process does not map it in? In particular
I want to map the CVMSEG for Cavium qemu-mips64 and qemu-mipsn32. The
addresses would be 0xFFFFFFFFFFFF8000 - 0xFFFFFFFFFFFFBFFF. I've looked at
target_mmap but it can't handle addresses that large. The lack of an
emulated mmu for 64 bit guests is going to be a problem.

[-- Attachment #2: Type: text/html, Size: 735 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CVMSEG Emulation
  2022-12-08 15:08 CVMSEG Emulation Christopher Wrogg
@ 2022-12-08 21:54 ` Jiaxun Yang
  2022-12-09 17:44   ` Christopher Wrogg
  0 siblings, 1 reply; 7+ messages in thread
From: Jiaxun Yang @ 2022-12-08 21:54 UTC (permalink / raw)
  To: Christopher Wrogg
  Cc: BALATON Zoltan via, Richard Henderson, Aleksandar Rikalo,
	Aurelien Jarno, Philippe Mathieu-Daudé


Hi,

This address range is located in KSEG3… Doesn’t seems to be a good location
for userspace program.

I think you have two options to make target_mmap work, the first would be rising
TARGET_VIRT_ADDR_SPACE_BITS to 64 bit. That may break some user space
applications storing pointer tags on higher bits.

The second would be mask CVMSEG base with TARGET_VIRT_ADDR_SPACE_BITS
before mmap, As higher VM address bits will be dropped when addressing guest VM,
that should provide a similar behaviour. Though you’ll have multiple alias for CVMSEG in
memory and application will be able to access CVMSEG with bits higher than
TARGET_VIRT_ADDR_SPACE_BITS set to any value. Don’t know if it will break anything,
AFAIK normal applications won't use this range.

Thanks
- Jiaxun 


> 2022年12月8日 15:08,Christopher Wrogg <cwrogg@umich.edu> 写道:
> 
> In userspace emulation how do I make a set of addresses always valid and initialized to 0 even though the process does not map it in? In particular I want to map the CVMSEG for Cavium qemu-mips64 and qemu-mipsn32. The addresses would be 0xFFFFFFFFFFFF8000 - 0xFFFFFFFFFFFFBFFF. I've looked at target_mmap but it can't handle addresses that large. The lack of an emulated mmu for 64 bit guests is going to be a problem.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CVMSEG Emulation
  2022-12-08 21:54 ` Jiaxun Yang
@ 2022-12-09 17:44   ` Christopher Wrogg
  2022-12-09 21:01     ` Jiaxun Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Wrogg @ 2022-12-09 17:44 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: BALATON Zoltan via, Richard Henderson, Aleksandar Rikalo,
	Aurelien Jarno, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

I tried both.

Option 1
    What I did:
        #undef TARGET_VIRT_ADDR_SPACE_BITS and #define
TARGET_VIRT_ADDR_SPACE_BITS 64
    The Result:
        perror reports "Cannot allocate memory"
Option 2:
    What I did:
        TARGET_VIRT_ADDR_SPACE_BITS for me is 30 so I masked by 0x3FFFFFFF
    The Result:
        The segfault persists and gdb reports the memory as inaccessible.

On Thu, Dec 8, 2022 at 4:55 PM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:

>
> Hi,
>
> This address range is located in KSEG3… Doesn’t seems to be a good location
> for userspace program.
>
> I think you have two options to make target_mmap work, the first would be
> rising
> TARGET_VIRT_ADDR_SPACE_BITS to 64 bit. That may break some user space
> applications storing pointer tags on higher bits.
>
> The second would be mask CVMSEG base with TARGET_VIRT_ADDR_SPACE_BITS
> before mmap, As higher VM address bits will be dropped when addressing
> guest VM,
> that should provide a similar behaviour. Though you’ll have multiple alias
> for CVMSEG in
> memory and application will be able to access CVMSEG with bits higher than
> TARGET_VIRT_ADDR_SPACE_BITS set to any value. Don’t know if it will break
> anything,
> AFAIK normal applications won't use this range.
>
> Thanks
> - Jiaxun
>
>
> > 2022年12月8日 15:08,Christopher Wrogg <cwrogg@umich.edu> 写道:
> >
> > In userspace emulation how do I make a set of addresses always valid and
> initialized to 0 even though the process does not map it in? In particular
> I want to map the CVMSEG for Cavium qemu-mips64 and qemu-mipsn32. The
> addresses would be 0xFFFFFFFFFFFF8000 - 0xFFFFFFFFFFFFBFFF. I've looked at
> target_mmap but it can't handle addresses that large. The lack of an
> emulated mmu for 64 bit guests is going to be a problem.
>
>

[-- Attachment #2: Type: text/html, Size: 2409 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CVMSEG Emulation
  2022-12-09 17:44   ` Christopher Wrogg
@ 2022-12-09 21:01     ` Jiaxun Yang
  2022-12-12 12:02       ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Jiaxun Yang @ 2022-12-09 21:01 UTC (permalink / raw)
  To: Christopher Wrogg
  Cc: BALATON Zoltan via, Richard Henderson, Aleksandar Rikalo,
	Aurelien Jarno, Philippe Mathieu-Daudé



> 2022年12月9日 17:44,Christopher Wrogg <cwrogg@umich.edu> 写道:
> 
> I tried both.
> 
> Option 1 
>     What I did:
>         #undef TARGET_VIRT_ADDR_SPACE_BITS and #define TARGET_VIRT_ADDR_SPACE_BITS 64
>     The Result:
>         perror reports "Cannot allocate memory"
> Option 2: 
>     What I did:
>         TARGET_VIRT_ADDR_SPACE_BITS for me is 30 so I masked by 0x3FFFFFFF
>     The Result:
>         The segfault persists and gdb reports the memory as inaccessible.

Hmm this looks wired for me, by no chance TARGET_VIRT_ADDR_SPACE_BITS for MIPS
can be 30, on N64 ABI build it should be 48 and 32 for N32 or O32 build.

It is defined in target/mips/cpu-param.h .

Thanks.

> 
> On Thu, Dec 8, 2022 at 4:55 PM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
> 
> Hi,
> 
> This address range is located in KSEG3… Doesn’t seems to be a good location
> for userspace program.
> 
> I think you have two options to make target_mmap work, the first would be rising
> TARGET_VIRT_ADDR_SPACE_BITS to 64 bit. That may break some user space
> applications storing pointer tags on higher bits.
> 
> The second would be mask CVMSEG base with TARGET_VIRT_ADDR_SPACE_BITS
> before mmap, As higher VM address bits will be dropped when addressing guest VM,
> that should provide a similar behaviour. Though you’ll have multiple alias for CVMSEG in
> memory and application will be able to access CVMSEG with bits higher than
> TARGET_VIRT_ADDR_SPACE_BITS set to any value. Don’t know if it will break anything,
> AFAIK normal applications won't use this range.
> 
> Thanks
> - Jiaxun 
> 
> 
> > 2022年12月8日 15:08,Christopher Wrogg <cwrogg@umich.edu> 写道:
> > 
> > In userspace emulation how do I make a set of addresses always valid and initialized to 0 even though the process does not map it in? In particular I want to map the CVMSEG for Cavium qemu-mips64 and qemu-mipsn32. The addresses would be 0xFFFFFFFFFFFF8000 - 0xFFFFFFFFFFFFBFFF. I've looked at target_mmap but it can't handle addresses that large. The lack of an emulated mmu for 64 bit guests is going to be a problem.
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CVMSEG Emulation
  2022-12-09 21:01     ` Jiaxun Yang
@ 2022-12-12 12:02       ` Peter Maydell
  2022-12-12 14:17         ` Christopher Wrogg
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2022-12-12 12:02 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: Christopher Wrogg, BALATON Zoltan via, Richard Henderson,
	Aleksandar Rikalo, Aurelien Jarno, Philippe Mathieu-Daudé

On Fri, 9 Dec 2022 at 21:03, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>
>
>
> > 2022年12月9日 17:44,Christopher Wrogg <cwrogg@umich.edu> 写道:
> >
> > I tried both.
> >
> > Option 1
> >     What I did:
> >         #undef TARGET_VIRT_ADDR_SPACE_BITS and #define TARGET_VIRT_ADDR_SPACE_BITS 64
> >     The Result:
> >         perror reports "Cannot allocate memory"
> > Option 2:
> >     What I did:
> >         TARGET_VIRT_ADDR_SPACE_BITS for me is 30 so I masked by 0x3FFFFFFF
> >     The Result:
> >         The segfault persists and gdb reports the memory as inaccessible.
>
> Hmm this looks wired for me, by no chance TARGET_VIRT_ADDR_SPACE_BITS for MIPS
> can be 30, on N64 ABI build it should be 48 and 32 for N32 or O32 build.
>
> It is defined in target/mips/cpu-param.h .

For 32-bit user-mode we currently set it to 31, on the theory that userspace
only gets access to the bottom half of the address space.

-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CVMSEG Emulation
  2022-12-12 12:02       ` Peter Maydell
@ 2022-12-12 14:17         ` Christopher Wrogg
  0 siblings, 0 replies; 7+ messages in thread
From: Christopher Wrogg @ 2022-12-12 14:17 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Jiaxun Yang, BALATON Zoltan via, Richard Henderson,
	Aleksandar Rikalo, Aurelien Jarno, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]

I am getting the 48 bits value on 64 bit hosts. Having said that, I still
have the two problems above with the suggested fixes.

On Mon, Dec 12, 2022 at 7:03 AM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Fri, 9 Dec 2022 at 21:03, Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
> >
> >
> >
> > > 2022年12月9日 17:44,Christopher Wrogg <cwrogg@umich.edu> 写道:
> > >
> > > I tried both.
> > >
> > > Option 1
> > >     What I did:
> > >         #undef TARGET_VIRT_ADDR_SPACE_BITS and #define
> TARGET_VIRT_ADDR_SPACE_BITS 64
> > >     The Result:
> > >         perror reports "Cannot allocate memory"
> > > Option 2:
> > >     What I did:
> > >         TARGET_VIRT_ADDR_SPACE_BITS for me is 30 so I masked by
> 0x3FFFFFFF
> > >     The Result:
> > >         The segfault persists and gdb reports the memory as
> inaccessible.
> >
> > Hmm this looks wired for me, by no chance TARGET_VIRT_ADDR_SPACE_BITS
> for MIPS
> > can be 30, on N64 ABI build it should be 48 and 32 for N32 or O32 build.
> >
> > It is defined in target/mips/cpu-param.h .
>
> For 32-bit user-mode we currently set it to 31, on the theory that
> userspace
> only gets access to the bottom half of the address space.
>
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 1852 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* CVMSEG Emulation
@ 2022-12-15  0:57 Christopher Wrogg
  0 siblings, 0 replies; 7+ messages in thread
From: Christopher Wrogg @ 2022-12-15  0:57 UTC (permalink / raw)
  To: BALATON Zoltan via
  Cc: Richard Henderson, Jiaxun Yang, Aleksandar Rikalo, Aurelien Jarno,
	Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

Was wondering if there was a follow up to this. Just a recap but I am
trying to map 0xFFFFFFFFFFFF8000 - 0xFFFFFFFFFFFFBFFF into a userspace
process's virtual address space. It falls squarely in KSEG3.

Here is what I have tried

Attempt 1
    What I did:
        #undef TARGET_VIRT_ADDR_SPACE_BITS and #define
TARGET_VIRT_ADDR_SPACE_BITS 64
    The Result:
        perror reports "Cannot allocate memory"
Attempt 2:
    What I did:
        TARGET_VIRT_ADDR_SPACE_BITS for me is 48 on amd64 so I masked by
0xFFFFFFFFFFFF
    The Result:
        perror reports "Cannot allocate memory"

[-- Attachment #2: Type: text/html, Size: 793 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-15  0:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-08 15:08 CVMSEG Emulation Christopher Wrogg
2022-12-08 21:54 ` Jiaxun Yang
2022-12-09 17:44   ` Christopher Wrogg
2022-12-09 21:01     ` Jiaxun Yang
2022-12-12 12:02       ` Peter Maydell
2022-12-12 14:17         ` Christopher Wrogg
  -- strict thread matches above, loose matches on Subject: below --
2022-12-15  0:57 Christopher Wrogg

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).