Hi Marc,

Thanks for your help. I studied the kvm_handle_guest_abort() handler, and
basically know the reason for "return 0".
But I still cannot solve the mapping problem.

I want to find a function or APIs, whose input parameters are (1) region
base IPA and size (2) mapped PA in Host (if IPA=PA, it could be better) (3)
R/W/X attributes.
Then, when I call the func(IPA start, IPA end, PA start, attr), I can get
the map.

Where should I follow? Should I follow the "translation fault path" again?
Or create the mapping function by myself?

Sincerely,
Wang

Marc Zyngier <[email protected]> 于2021年10月17日周日 上午5:19写道:

> On Sat, 16 Oct 2021 13:21:01 +0100,
> Chenxu Wang <[email protected]> wrote:
> >
> > Hi all,
> >
> > I am facing two problems with the Stage-2 translation in KVM.
> >
> > (1)
> > I reserve a memory region (e.g., 0xa000_0000 ~ 0xa020_0000) from DRAM
> space
> > of HostOS, and fill it with some values. Then ask a GuestVM to access
> this
> > region.
> >
> > void __iomem *region=ioremap(0xa0000000, 0x1000);
> > uint32_t val=ioread32(region);
> >
> > But I get value 0, which is not the expected value.
>
> It is the expected behaviour.
>
> > I guess the reason is that the Stage-2 translation of the GuestVM does
> not
> > map the reserved region, but it should return a translation fault, rather
> > than 0. So I feel confused, could you provide some helpful explanation?
>
> Why should the guest see a translation fault? After all, the whole
> point of KVM is to transparently handle the translation fault and map
> a page on demand.
>
> > (2)
> > I consider mapping a region with the Stage-2 translation. I find that KVM
> > create the stage-2 table with kvm_alloc_stage2_pgd(). But I could not
> find
> > a function that can "arbitrarily add a stage-2 mapping to the physical
> > address in HostOS" when the VM is activated.
> >
> > Could you provide such functions?
>
> Follow the translation fault path in KVM, and you will find what you
> are asking for.
>
>         M.
>
> --
> Without deviation from the norm, progress is not possible.
>
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Reply via email to