From: Andi Kleen <andi@firstfloor.org>
To: Matt Fleming <matt@console-pimps.org>
Cc: linux-kernel@vger.kernel.org,
"H. Peter Anvin" <hpa@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
Mike Waychison <mikew@google.com>,
Matthew Garrett <mjg@redhat.com>
Subject: Re: [PATCH 8/9] x86, efi: EFI boot stub support
Date: Thu, 11 Aug 2011 11:09:35 -0700 [thread overview]
Message-ID: <m2k4ajn7kw.fsf@firstfloor.org> (raw)
In-Reply-To: <1313060386-4858-9-git-send-email-matt@console-pimps.org> (Matt Fleming's message of "Thu, 11 Aug 2011 11:59:45 +0100")
Matt Fleming <matt@console-pimps.org> writes:
> +
> + status = efi_call_phys3(sys_table->boottime->allocate_pool,
> + EFI_LOADER_DATA, sizeof(*idt),
> + (void **)&idt);
> + if (status != EFI_SUCCESS)
> + goto fail;
> +
> + idt->size = 0;
> + idt->address = 0;
> +
> + status = make_boot_params(boot_params, image, handle);
> + if (status != EFI_SUCCESS)
> + goto fail;
> +
> + memset((char *)gdt->address, 0x0, gdt->size);
> + desc = (u64 *)gdt->address;
> +
> + /*
> + * 4Gb - (0x100000*0x1000 = 4Gb)
> + * base address=0
> + * code read/exec
> + * granularity=4096, 386 (+5th nibble of limit)
> + */
> + desc[2] = 0x00cf9a000000ffff;
> +
> + /*
> + * 4Gb - (0x100000*0x1000 = 4Gb)
> + * base address=0
> + * data read/write
> + * granularity=4096, 386 (+5th nibble of limit)
> + */
> + desc[3] = 0x00cf92000000ffff;
> +
> + /* Task segment value */
> + desc[4] = 0x0080890000000000;
The code would benefit from more variables/defines and less magic numbers.
I assume this is all virtual, otherwise it would be really scary.
> + asm volatile ("lidt %0" :: "m" (*idt));
> + asm volatile ("lgdt %0" :: "m" (*gdt));
> +
> + asm volatile("cli");
::: "memory" to avoid moving
> +
> + return boot_params;
> +fail:
> + return NULL;
Does the caller actually something useful here for NULL? Better to have
messages when any of this fails.
> +int memcmp(const void *s1, const void *s2, size_t len)
> +{
> + u8 diff;
> + asm("repe; cmpsb; setnz %0"
> + : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
This doesn't describe to gcc that the inline assembler
reads s1 and s2. At the minimum add a memory clobber.
> +
> +/**
> + * strlen - Find the length of a string
> + * @s: The string to be sized
> + */
> +size_t strlen(const char *s)
> +{
> + const char *sc;
> +
> + for (sc = s; *sc != '\0'; ++sc)
> + /* nothing */;
> + return sc - s;
> +}
Why not just link in/#include lib/string.c ?
-Andi
--
ak@linux.intel.com -- Speaking for myself only
next prev parent reply other threads:[~2011-08-11 18:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 10:59 [PATCH 0/9] x86 EFI boot stub Matt Fleming
2011-08-11 10:59 ` [PATCH 1/9] x86: Don't use magic strings for EFI loader signature Matt Fleming
2011-08-11 10:59 ` [PATCH 2/9] efi.h: Add struct definition for boot time services Matt Fleming
2011-08-11 10:59 ` [PATCH 3/9] efi.h: Add efi_image_loaded_t Matt Fleming
2011-08-11 10:59 ` [PATCH 4/9] efi.h: Add allocation types for boottime->allocate_pages() Matt Fleming
2011-08-11 10:59 ` [PATCH 5/9] efi.h: Add graphics protocol guid Matt Fleming
2011-08-11 10:59 ` [PATCH 6/9] efi.h: Add boottime->locate_handle search types Matt Fleming
2011-08-11 10:59 ` [PATCH 7/9] efi: Add EFI file I/O data types Matt Fleming
2011-08-11 10:59 ` [PATCH 8/9] x86, efi: EFI boot stub support Matt Fleming
2011-08-11 18:09 ` Andi Kleen [this message]
2011-08-17 11:46 ` Matt Fleming
2011-08-11 10:59 ` [PATCH 9/9] x86, efi: Make efi_call_phys_prelog() CONFIG_RELOCATABLE-aware Matt Fleming
2011-08-11 13:05 ` [PATCH 0/9] x86 EFI boot stub Maarten Lankhorst
2011-08-11 15:14 ` Matt Fleming
2011-08-11 17:55 ` Maarten Lankhorst
2011-08-26 12:29 ` Matt Fleming
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=m2k4ajn7kw.fsf@firstfloor.org \
--to=andi@firstfloor.org \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@console-pimps.org \
--cc=mikew@google.com \
--cc=mingo@elte.hu \
--cc=mjg@redhat.com \
--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 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.