mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
	virtualization <virtualization@lists.linux-foundation.org>,
	Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH 1/5] lguest host feedback tidyups
Date: Mon, 14 May 2007 15:38:04 +1000	[thread overview]
Message-ID: <1179121084.23513.186.camel@localhost.localdomain> (raw)
In-Reply-To: <1179107062.23513.152.camel@localhost.localdomain>

On Mon, 2007-05-14 at 11:44 +1000, Rusty Russell wrote:
> On Sun, 2007-05-13 at 19:39 +0100, Al Viro wrote:
> > >  static void push_guest_stack(struct lguest *lg, u32 __user **gstack, u32 val)
> > >  {
> > > -	lgwrite_u32(lg, (u32)--(*gstack), val);
> > > +	lgwrite_u32(lg, (__force u32)--(*gstack), val);
> > >  }
> > 
> > Now, _that_ is just plain dumb.  Why not declare that lgwrite_u32() as taking
> > u32 __user * as argument and kill the casts?
> 
> Last I tried, this turns out to create even more casts.

But after thinking harder... changing the gstack type gets rid of three
casts, including that one.  Thanks!

How's this?
Rusty.
== 
Reduce number of casts in set_guest_interrupt().

Al Viro pointed out the ugly cast in push_lguest_stack(); as this is
only called from set_guest_interrupt() which casts the arg in the
first place, let's stick with unsigned long the whole way through.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff -r 16e417365c64 drivers/lguest/interrupts_and_traps.c
--- a/drivers/lguest/interrupts_and_traps.c	Mon May 14 15:05:48 2007 +1000
+++ b/drivers/lguest/interrupts_and_traps.c	Mon May 14 15:22:38 2007 +1000
@@ -16,24 +16,25 @@ static int idt_present(u32 lo, u32 hi)
 	return (hi & 0x8000);
 }
 
-static void push_guest_stack(struct lguest *lg, u32 __user **gstack, u32 val)
-{
-	lgwrite_u32(lg, (unsigned long)--(*gstack), val);
+static void push_guest_stack(struct lguest *lg, unsigned long *gstack, u32 val)
+{
+	*gstack -= 4;
+	lgwrite_u32(lg, *gstack, val);
 }
 
 static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err)
 {
-	u32 __user *gstack;
+	unsigned long gstack;
 	u32 eflags, ss, irq_enable;
 
 	/* If they want a ring change, we use new stack and push old ss/esp */
 	if ((lg->regs->ss&0x3) != GUEST_PL) {
-		gstack = (u32 __user *)guest_pa(lg, lg->esp1);
+		gstack = guest_pa(lg, lg->esp1);
 		ss = lg->ss1;
 		push_guest_stack(lg, &gstack, lg->regs->ss);
 		push_guest_stack(lg, &gstack, lg->regs->esp);
 	} else {
-		gstack = (u32 __user *)guest_pa(lg, lg->regs->esp);
+		gstack = guest_pa(lg, lg->regs->esp);
 		ss = lg->regs->ss;
 	}
 
@@ -53,7 +54,7 @@ static void set_guest_interrupt(struct l
 
 	/* Change the real stack so switcher returns to trap handler */
 	lg->regs->ss = ss;
-	lg->regs->esp = (unsigned long)gstack + lg->page_offset;
+	lg->regs->esp = gstack + lg->page_offset;
 	lg->regs->cs = (__KERNEL_CS|GUEST_PL);
 	lg->regs->eip = idt_address(lo, hi);
 



  reply	other threads:[~2007-05-14  5:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-11  1:17 [PATCH 0/5] lguest " Rusty Russell
2007-05-11  1:19 ` [PATCH 1/5] lguest host " Rusty Russell
2007-05-11  1:21   ` [PATCH 2/5] lguest guest " Rusty Russell
2007-05-11  1:22     ` [PATCH 3/5] lguest network driver " Rusty Russell
2007-05-11  1:23       ` [PATCH 4/5] lguest block " Rusty Russell
2007-05-11  1:24         ` [PATCH 5/5] lguest console " Rusty Russell
2007-05-13  4:08         ` [PATCH 4/5] lguest block " Rusty Russell
2007-05-13  3:52       ` [PATCH 3/5] lguest network " Rusty Russell
2007-05-13  4:12         ` Rusty Russell
2007-05-11  6:56     ` [PATCH 2/5] lguest guest " Christoph Hellwig
2007-05-11  7:31       ` Rusty Russell
2007-05-11  7:40         ` Christoph Hellwig
2007-05-13  1:00           ` Rusty Russell
2007-05-13  3:48       ` Rusty Russell
2007-05-13 18:43     ` Al Viro
2007-05-14  7:11       ` Rusty Russell
2007-05-13  4:07   ` [PATCH 1/5] lguest host " Rusty Russell
2007-05-13 18:47     ` Al Viro
2007-05-14  1:30       ` Rusty Russell
2007-05-13 18:39   ` Al Viro
2007-05-14  1:44     ` Rusty Russell
2007-05-14  5:38       ` Rusty Russell [this message]
2007-05-11  6:53 ` [PATCH 0/5] lguest " Christoph Hellwig

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=1179121084.23513.186.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    --cc=viro@ftp.linux.org.uk \
    --cc=virtualization@lists.linux-foundation.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

Powered by JetHome