All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org,
	Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [kvmtool][PATCH] arm64: Obtain text offset from kernel image
Date: Fri, 05 Jun 2020 17:07:02 +0100	[thread overview]
Message-ID: <8eeb07b54718d83de6262434c08774fa@kernel.org> (raw)
In-Reply-To: <e9045c9e-f1c1-a6aa-9a19-37dc7ea02038@arm.com>

Hi Alex,

On 2020-06-05 13:16, Alexandru Elisei wrote:
> Hi Marc,
> 
> On 6/5/20 11:49 AM, Marc Zyngier wrote:
>> Recent changes made to Linux 5.8 have outlined that kvmtool
>> hardcodes the text offset instead of reading it from the arm64
>> image itself.
>> 
>> To address this, import the image header structure into kvmtool
>> and do the right thing. 32bit guests are still loaded to their
>> usual locations.
>> 
>> Reported-by: Ard Biesheuvel <ardb@kernel.org>
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>>  Makefile                           |  1 +
>>  arm/aarch32/include/kvm/kvm-arch.h |  2 +-
>>  arm/aarch64/include/asm/image.h    | 59 
>> ++++++++++++++++++++++++++++++
>>  arm/aarch64/include/kvm/kvm-arch.h |  5 +--
>>  arm/aarch64/kvm.c                  | 30 +++++++++++++++
>>  arm/kvm.c                          |  2 +-
>>  6 files changed, 94 insertions(+), 5 deletions(-)
>>  create mode 100644 arm/aarch64/include/asm/image.h
>>  create mode 100644 arm/aarch64/kvm.c
>> 
>> [..]
> 
> This is a great addition to kvmtool, thank you! Before I do a more 
> in-depth
> review, I have some general questions.
> 
> Regarding the actual value of text_offset, the booting.rst document 
> says:
> 
> "Prior to v3.17, the endianness of text_offset was not specified.  In
> these cases
> image_size is zero and text_offset is 0x80000 in the endianness of the 
> kernel. 
> Where image_size is non-zero image_size is little-endian and must be 
> respected. 
> Where image_size is zero, text_offset can be assumed to be 0x80000".
> 
> All header fields are declared little-endian, which looks to me like it 
> would
> break kernels older than 3.17. If that was intentional, I think it's 
> worth
> documenting somewhere, or at least a comment for the 
> kvm__arch_get_kern_offset
> function.

TBH, I didn't give pre-3.17 *big-endian* much thought. Happy to document
it though.

> 
> Now that we are parsing the kernel header, have you considered
> checking the magic
> number to make sure the user specified a valid kernel image? It might
> save someone
> some time debugging why the kernel isn't booting, if, for example, they 
> are
> booting an armv7 kernel, but they forgot to specify --aarch32.

That'd be interesting. I'd be reluctant to prevent it from booting
altogether, but I can definitely detect the lack of signature and
print a warning.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: Julien Thierry <julien.thierry.kdev@gmail.com>,
	Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org,
	Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [kvmtool][PATCH] arm64: Obtain text offset from kernel image
Date: Fri, 05 Jun 2020 17:07:02 +0100	[thread overview]
Message-ID: <8eeb07b54718d83de6262434c08774fa@kernel.org> (raw)
In-Reply-To: <e9045c9e-f1c1-a6aa-9a19-37dc7ea02038@arm.com>

Hi Alex,

On 2020-06-05 13:16, Alexandru Elisei wrote:
> Hi Marc,
> 
> On 6/5/20 11:49 AM, Marc Zyngier wrote:
>> Recent changes made to Linux 5.8 have outlined that kvmtool
>> hardcodes the text offset instead of reading it from the arm64
>> image itself.
>> 
>> To address this, import the image header structure into kvmtool
>> and do the right thing. 32bit guests are still loaded to their
>> usual locations.
>> 
>> Reported-by: Ard Biesheuvel <ardb@kernel.org>
>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>> ---
>>  Makefile                           |  1 +
>>  arm/aarch32/include/kvm/kvm-arch.h |  2 +-
>>  arm/aarch64/include/asm/image.h    | 59 
>> ++++++++++++++++++++++++++++++
>>  arm/aarch64/include/kvm/kvm-arch.h |  5 +--
>>  arm/aarch64/kvm.c                  | 30 +++++++++++++++
>>  arm/kvm.c                          |  2 +-
>>  6 files changed, 94 insertions(+), 5 deletions(-)
>>  create mode 100644 arm/aarch64/include/asm/image.h
>>  create mode 100644 arm/aarch64/kvm.c
>> 
>> [..]
> 
> This is a great addition to kvmtool, thank you! Before I do a more 
> in-depth
> review, I have some general questions.
> 
> Regarding the actual value of text_offset, the booting.rst document 
> says:
> 
> "Prior to v3.17, the endianness of text_offset was not specified.  In
> these cases
> image_size is zero and text_offset is 0x80000 in the endianness of the 
> kernel. 
> Where image_size is non-zero image_size is little-endian and must be 
> respected. 
> Where image_size is zero, text_offset can be assumed to be 0x80000".
> 
> All header fields are declared little-endian, which looks to me like it 
> would
> break kernels older than 3.17. If that was intentional, I think it's 
> worth
> documenting somewhere, or at least a comment for the 
> kvm__arch_get_kern_offset
> function.

TBH, I didn't give pre-3.17 *big-endian* much thought. Happy to document
it though.

> 
> Now that we are parsing the kernel header, have you considered
> checking the magic
> number to make sure the user specified a valid kernel image? It might
> save someone
> some time debugging why the kernel isn't booting, if, for example, they 
> are
> booting an armv7 kernel, but they forgot to specify --aarch32.

That'd be interesting. I'd be reluctant to prevent it from booting
altogether, but I can definitely detect the lack of signature and
print a warning.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-06-05 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 10:49 [kvmtool][PATCH] arm64: Obtain text offset from kernel image Marc Zyngier
2020-06-05 10:49 ` Marc Zyngier
2020-06-05 12:16 ` Alexandru Elisei
2020-06-05 12:16   ` Alexandru Elisei
2020-06-05 16:07   ` Marc Zyngier [this message]
2020-06-05 16:07     ` Marc Zyngier

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=8eeb07b54718d83de6262434c08774fa@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=ardb@kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.