From: Julien Grall <julien.grall@arm.com>
To: Sergej Proskurin <proskurin@sec.in.tum.de>,
xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v7 12/14] arm/mem_access: Add long-descriptor based gpt
Date: Thu, 20 Jul 2017 16:20:33 +0100 [thread overview]
Message-ID: <ad23e2d5-46e5-ff30-c586-cfc56be29dc2@arm.com> (raw)
In-Reply-To: <20170718122507.11873-13-proskurin@sec.in.tum.de>
Hi,
On 18/07/17 13:25, Sergej Proskurin wrote:
> + /*
> + * The starting level is the number of strides (grainsizes[gran] - 3)
> + * needed to consume the input address (ARM DDI 0487B.a J1-5924).
> + */
> + level = 4 - DIV_ROUND_UP((input_size - grainsizes[gran]), (grainsizes[gran] - 3));
> +
> + /* Get the IPA output_size. */
> + ret = get_ipa_output_size(d, tcr, &output_size);
> + if ( ret )
> + return -EFAULT;
> +
> + /* Make sure the base address does not exceed its configured size. */
> + ret = check_base_size(output_size, ttbr);
> + if ( !ret )
> + return -EFAULT;
> +
> + /*
> + * Compute the base address of the first level translation table that is
> + * given by TTBRx_EL1 (ARM DDI 0487B.a D4-2024 and J1-5926).
> + */
> + mask = GENMASK_ULL(47, grainsizes[gran]);
> + paddr = (ttbr & mask);
> +
> + for ( ; ; level++ )
> + {
> + /*
> + * Add offset given by the GVA to the translation table base address.
> + * Shift the offset by 3 as it is 8-byte aligned.
> + */
> + paddr |= offsets[gran][level] << 3;
> +
> + /* Access the guest's memory to read only one PTE. */
> + ret = access_guest_memory_by_ipa(d, paddr, &pte, sizeof(lpae_t), false);
While working on other bit of Xen, it occurred to me that
access_guest_memory_by_ipa will take the p2m lock. However it is already
taken by another caller in the stack (see get_page_from_gva).
This means you rely on the p2m lock to be recursive. I don't think we
make this assumption in any p2m code at the moment. I think it is fine
with the current locking (we are using read-write lock).
I am not a big fan of nested lock, but I can't see how to do it properly
here. Nevertheless, I would like a comment on top of the p2m rwlock to
explain we have place using nested p2m locked. So if we ever decide to
modify the lock, we will not get get caught with a deadlock in the
memaccess code.
I will review the rest of the patch later.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-20 15:20 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 12:24 [PATCH v7 00/14] arm/mem_access: Walk guest page tables in SW if mem_access is active Sergej Proskurin
2017-07-18 12:24 ` [PATCH v7 01/14] arm/mem_access: Add and cleanup (TCR_|TTBCR_)* defines Sergej Proskurin
2017-07-18 12:24 ` [PATCH v7 02/14] arm/mem_access: Move PAGE_*_* macros to xen/page-defs.h Sergej Proskurin
2017-07-18 12:24 ` [PATCH v7 03/14] arm/mem_access: Add defines supporting PTs with varying page sizes Sergej Proskurin
2017-07-18 12:24 ` [PATCH v7 04/14] arm/lpae: Introduce lpae_is_page helper Sergej Proskurin
2017-07-18 12:24 ` [PATCH v7 05/14] arm/mem_access: Add short-descriptor pte typedefs and macros Sergej Proskurin
2017-07-18 12:24 ` [PATCH v7 06/14] arm/mem_access: Introduce GV2M_EXEC permission Sergej Proskurin
2017-07-18 12:25 ` [PATCH v7 07/14] arm/mem_access: Introduce BIT_ULL bit operation Sergej Proskurin
2017-07-18 12:25 ` [PATCH v7 08/14] arm/mem_access: Introduce GENMASK_ULL " Sergej Proskurin
2017-07-18 12:25 ` [PATCH v7 09/14] arm/guest_access: Move vgic_access_guest_memory to guest_access.h Sergej Proskurin
2017-07-18 12:25 ` [PATCH v7 10/14] arm/guest_access: Rename vgic_access_guest_memory Sergej Proskurin
2017-07-18 12:25 ` [PATCH v7 11/14] arm/mem_access: Add software guest-page-table walk Sergej Proskurin
2017-07-18 12:25 ` [PATCH v7 12/14] arm/mem_access: Add long-descriptor based gpt Sergej Proskurin
2017-07-20 15:20 ` Julien Grall [this message]
2017-07-18 12:25 ` [PATCH v7 13/14] arm/mem_access: Add short-descriptor " Sergej Proskurin
2017-08-08 15:17 ` Sergej Proskurin
2017-08-08 15:18 ` Julien Grall
2017-08-08 15:28 ` Sergej Proskurin
2017-08-08 16:20 ` Andrew Cooper
2017-08-08 16:30 ` Sergej Proskurin
2017-08-09 8:18 ` Sergej Proskurin
2017-08-09 9:14 ` Andrew Cooper
2017-07-18 12:25 ` [PATCH v7 14/14] arm/mem_access: Walk the guest's pt in software Sergej Proskurin
2017-07-31 14:38 ` [PATCH v7 00/14] arm/mem_access: Walk guest page tables in SW if mem_access is active Julien Grall
2017-08-04 9:15 ` Sergej Proskurin
2017-08-08 12:17 ` Sergej Proskurin
2017-08-08 12:33 ` Julien Grall
2017-08-08 13:24 ` Julien Grall
2017-08-08 14:47 ` Sergej Proskurin
2017-08-08 14:58 ` Andrew Cooper
2017-08-08 15:04 ` Sergej Proskurin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad23e2d5-46e5-ff30-c586-cfc56be29dc2@arm.com \
--to=julien.grall@arm.com \
--cc=proskurin@sec.in.tum.de \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).