From: tip-bot for Paul Bolle <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, pebolle@tiscali.nl,
rusty@rustcorp.com.au, tglx@linutronix.de, mingo@kernel.org
Subject: [tip:x86/cleanups] lguest: Read length of device_cap later
Date: Fri, 10 Jun 2016 02:42:52 -0700 [thread overview]
Message-ID: <tip-7faf90ef995ea470f32f43810266ece8ac8ba6c7@git.kernel.org> (raw)
In-Reply-To: <1457006501-5377-2-git-send-email-pebolle@tiscali.nl>
Commit-ID: 7faf90ef995ea470f32f43810266ece8ac8ba6c7
Gitweb: http://git.kernel.org/tip/7faf90ef995ea470f32f43810266ece8ac8ba6c7
Author: Paul Bolle <pebolle@tiscali.nl>
AuthorDate: Thu, 3 Mar 2016 13:01:40 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 10 Jun 2016 11:39:09 +0200
lguest: Read length of device_cap later
Read the length of the capability with type VIRTIO_PCI_CAP_DEVICE_CFG
only when we're sure we're going to need it. Which is just before the
check whether the virtio console actually has an emerg_wr field.
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: lguest@lists.ozlabs.org
Link: http://lkml.kernel.org/r/1457006501-5377-2-git-send-email-pebolle@tiscali.nl
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/lguest/boot.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 3847e73..146d11c 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -1258,7 +1258,7 @@ static void probe_pci_console(void)
u8 vndr = read_pci_config_byte(0, 1, 0, cap);
if (vndr == PCI_CAP_ID_VNDR) {
u8 type, bar;
- u32 offset, length;
+ u32 offset;
type = read_pci_config_byte(0, 1, 0,
cap + offsetof(struct virtio_pci_cap, cfg_type));
@@ -1266,15 +1266,12 @@ static void probe_pci_console(void)
cap + offsetof(struct virtio_pci_cap, bar));
offset = read_pci_config(0, 1, 0,
cap + offsetof(struct virtio_pci_cap, offset));
- length = read_pci_config(0, 1, 0,
- cap + offsetof(struct virtio_pci_cap, length));
switch (type) {
case VIRTIO_PCI_CAP_DEVICE_CFG:
if (bar == 0) {
device_cap = cap;
device_offset = offset;
- device_len = length;
}
break;
case VIRTIO_PCI_CAP_PCI_CFG:
@@ -1297,6 +1294,8 @@ static void probe_pci_console(void)
* emerg_wr. If it doesn't support VIRTIO_CONSOLE_F_EMERG_WRITE
* it should ignore the access.
*/
+ device_len = read_pci_config(0, 1, 0,
+ device_cap + offsetof(struct virtio_pci_cap, length));
if (device_len < (offsetof(struct virtio_console_config, emerg_wr)
+ sizeof(u32))) {
printk(KERN_ERR "lguest: console missing emerg_wr field\n");
next prev parent reply other threads:[~2016-06-10 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 12:01 [PATCH 0/2] lguest: Minor cleanups of boot code Paul Bolle
2016-03-03 12:01 ` [PATCH 1/2] lguest: read length of device_cap later Paul Bolle
2016-06-10 9:42 ` tip-bot for Paul Bolle [this message]
2016-03-03 12:01 ` [PATCH 2/2] lguest: read offset " Paul Bolle
2016-06-10 9:43 ` [tip:x86/cleanups] lguest: Read " tip-bot for Paul Bolle
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=tip-7faf90ef995ea470f32f43810266ece8ac8ba6c7@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pebolle@tiscali.nl \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/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