On 31/01/18 12:39, Alex Shi wrote:
+static void __copy_hyp_vect_bpi(int slot, const char *hyp_vecs_start,
const char *hyp_vecs_end)
+{
- void *dst = lm_alias(__bp_harden_hyp_vecs_start + slot * SZ_2K)
Hi Will,
Here lm_alias get the virtual address of __bp_harden_hyp_vecs_start from 0xffff000008098800(for example) to 0xffff800008098800 Code basing on v4.15-rc3 works well for this new address 0xffff80000.... but code basing on v4.9 will report null page:
Unable to handle kernel paging request at virtual address ffff8000000....
And without the lm_alias, the kernel booted well. Another place used lm_alias is in kvm_get_hyp_vector(),
Is this safe to drop lm_alias? Or is there some place to request pages for aliaed adderss?
The question you have to ask yourself is whether or not the address you're getting for __bp_harden_hyp_vecs_start is from the linear mapping or from another range. If the former, lm_alias is not necessary (but you may want to find out why it gives you something that is unexpected). If the latter, then you really need to translate it to the linear map, as you're not going to be able to write to kernel text via its execution mapping.
Hi Marc,
Thanks a lot for help! :)
Seems I still stuck and confused in this address alia issue. Is there some shared vector need accessed from both host(hyp) and kvm(normal kernel)? or hyp need copy some vectors to (raw address - kimg) for itself? And if not in hyp, kernel only use raw address?
I really don't understand your questions, so let me explain how things work:
- The kernel embeds all of the KVM text. Some of that text is meant to be mapped at EL2.
- All the mappings at HYP are at an offset from the linear mapping, and you can convert a linear mapping VA to a HYP VA using kern_hyp_va().
- If you have a kernel address, you have to convert it to a linear map address first before feeding it to the hypervisor.
- Nothing is copied from kernel to HYP. Things are just mapped differently. The only copy is part of this patch, and generates the code in place. It doesn't affect how things are mapped.
- We only map a tiny bit of the linear map in HYP (HYP text, vcpu and kvm structures).
I still confused on lm_alias using, because, the v4.15 kernel run on EL1 which works with lm_alias address 0xffff80... but v4.9 kernel only works with raw 'dst' address 0xffff00... on EL1. And the same time, juno r2 run on EL2 which report null address on raw address 0xffff00...
What do you mean by "null address" or "raw address"?
As for kvm_get_hyp_vector, same thing. We only map the linear map at EL2, so you really need to pick the right set of VAs, or kern_hyp_va is going to point you to lalaland (and that will be pretty final).
the hyp runs in el2 and use lm_aliaed address?
See above. If you have a kernel address and want to convert it to a HYP address, you must turn it into a linear map address first, then turn it into a HYP VA.
M.