From: Sergej Proskurin <proskurin@sec.in.tum.de>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@arm.com>,
xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v7 13/14] arm/mem_access: Add short-descriptor based gpt
Date: Wed, 9 Aug 2017 10:18:03 +0200 [thread overview]
Message-ID: <a24f5906-a50c-8b65-90b2-8366b278ff1b@sec.in.tum.de> (raw)
In-Reply-To: <cb34c2d1-3e22-8f1b-b54c-5caeb0851424@sec.in.tum.de>
Hi Andrew,
>>> diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c
>>> index b258248322..7f34a2b1d3 100644
>>> --- a/xen/arch/arm/guest_walk.c
>>> +++ b/xen/arch/arm/guest_walk.c
>>> @@ -112,7 +112,12 @@ static int guest_walk_sd(const struct vcpu *v,
>>> * level translation table does not need to be page aligned.
>>> */
>>> mask = GENMASK(19, 12);
>>> - paddr = (pte.walk.base << 10) | ((gva & mask) >> 10);
>>> + /*
>>> + * Cast pte.walk.base to paddr_t to cope with C type promotion
>>> of types
>>> + * smaller than int. Otherwise pte.walk.base would be casted to
>>> int and
>>> + * subsequently sign extended, thus leading to a wrong value.
>>> + */
>>> + paddr = ((paddr_t)pte.walk.base << 10) | ((gva & mask) >> 10);
>> Why not change the bitfield type from unsigned int to paddr_t ?
>>
>> The result is 100% less liable to go wrong in this way.
>>
Actually, AFAICT we would get into same troubles as before. Because of
the fact that the bitfield is smaller than an int (22 bit), it would be
first promoted to int and then we would face the same issues as we
already had.
If that is ok for you, I will resubmit the next patch without changing
the type of the bitfield. If you should not agree with me, I would
gladly discuss this issue in v8 :)
Thanks,
~Sergej
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-09 8:18 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
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 [this message]
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=a24f5906-a50c-8b65-90b2-8366b278ff1b@sec.in.tum.de \
--to=proskurin@sec.in.tum.de \
--cc=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--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).