Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/rw/uml

Pull UML updates from Richard Weinberger:
 "Most changes are bug fixes and cleanups"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml:
  um: missing checks of __put_user()/__get_user() return values
  um: stub_rt_sigsuspend isn't needed these days anymore
  um/x86: merge (and trim) 32- and 64-bit variants of ptrace.h
  irq: Remove irq_chip->release()
  um: Remove CONFIG_IRQ_RELEASE_METHOD
  um: Remove usage of irq_chip->release()
  um: Implement um_free_irq()
  um: Fix __swp_type()
  um: Implement a custom pte_same() function
  um: Add BUG() to do_ops()'s error path
  um: Remove unused variables
  um: bury unused _TIF_RESTORE_SIGMASK
  um: wrong sigmask saved in case of multiple sigframes
  um: add TIF_NOTIFY_RESUME
  um: ->restart_block.fn needs to be reset on sigreturn
  • Loading branch information
Linus Torvalds committed May 23, 2012
2 parents 1d767ca + 2ccf62b commit 3a8580f
Show file tree
Hide file tree
Showing 31 changed files with 201 additions and 340 deletions.
5 changes: 0 additions & 5 deletions arch/um/Kconfig.common
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ config GENERIC_CLOCKEVENTS
bool
default y

# Used in kernel/irq/manage.c and include/linux/irq.h
config IRQ_RELEASE_METHOD
bool
default y

config HZ
int
default 100
Expand Down
1 change: 0 additions & 1 deletion arch/um/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ CONFIG_LOCKDEP_SUPPORT=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_IRQ_RELEASE_METHOD=y
CONFIG_HZ=100

#
Expand Down
9 changes: 5 additions & 4 deletions arch/um/drivers/chan_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/tty_flip.h>
#include "chan.h"
#include "os.h"
#include "irq_kern.h"

#ifdef CONFIG_NOCONFIG_CHAN
static void *not_configged_init(char *str, int device,
Expand Down Expand Up @@ -213,9 +214,9 @@ void free_irqs(void)
chan = list_entry(ele, struct chan, free_list);

if (chan->input && chan->enabled)
free_irq(chan->line->driver->read_irq, chan);
um_free_irq(chan->line->driver->read_irq, chan);
if (chan->output && chan->enabled)
free_irq(chan->line->driver->write_irq, chan);
um_free_irq(chan->line->driver->write_irq, chan);
chan->enabled = 0;
}
}
Expand All @@ -234,9 +235,9 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
}
else {
if (chan->input && chan->enabled)
free_irq(chan->line->driver->read_irq, chan);
um_free_irq(chan->line->driver->read_irq, chan);
if (chan->output && chan->enabled)
free_irq(chan->line->driver->write_irq, chan);
um_free_irq(chan->line->driver->write_irq, chan);
chan->enabled = 0;
}
if (chan->ops->close != NULL)
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ struct winch {
static void __free_winch(struct work_struct *work)
{
struct winch *winch = container_of(work, struct winch, work);
free_irq(WINCH_IRQ, winch);
um_free_irq(WINCH_IRQ, winch);

if (winch->pid != -1)
os_kill_process(winch->pid, 1);
Expand Down
4 changes: 2 additions & 2 deletions arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int uml_net_close(struct net_device *dev)

netif_stop_queue(dev);

free_irq(dev->irq, dev);
um_free_irq(dev->irq, dev);
if (lp->close != NULL)
(*lp->close)(lp->fd, &lp->user);
lp->fd = -1;
Expand Down Expand Up @@ -835,7 +835,7 @@ static void close_devices(void)
spin_lock(&opened_lock);
list_for_each(ele, &opened) {
lp = list_entry(ele, struct uml_net_private, list);
free_irq(lp->dev->irq, lp->dev);
um_free_irq(lp->dev->irq, lp->dev);
if ((lp->close != NULL) && (lp->fd >= 0))
(*lp->close)(lp->fd, &lp->user);
if (lp->remove != NULL)
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/port_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ int port_wait(void *data)
* connection. Then we loop here throwing out failed
* connections until a good one is found.
*/
free_irq(TELNETD_IRQ, conn);
um_free_irq(TELNETD_IRQ, conn);

if (conn->fd >= 0)
break;
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/xterm_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int xterm_fd(int socket, int *pid_out)
* isn't set) this will hang... */
wait_for_completion(&data->ready);

free_irq(XTERM_IRQ, data);
um_free_irq(XTERM_IRQ, data);

ret = data->new_fd;
*pid_out = data->pid;
Expand Down
10 changes: 8 additions & 2 deletions arch/um/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ static inline void set_pte(pte_t *pteptr, pte_t pteval)
}
#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)

#define __HAVE_ARCH_PTE_SAME
static inline int pte_same(pte_t pte_a, pte_t pte_b)
{
return !((pte_val(pte_a) ^ pte_val(pte_b)) & ~_PAGE_NEWPAGE);
}

/*
* Conversion functions: convert a page and protection to a page entry,
* and a page entry and page directory to the page they refer to.
Expand Down Expand Up @@ -348,11 +354,11 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
#define update_mmu_cache(vma,address,ptep) do ; while (0)

/* Encode and de-code a swap entry */
#define __swp_type(x) (((x).val >> 4) & 0x3f)
#define __swp_type(x) (((x).val >> 5) & 0x1f)
#define __swp_offset(x) ((x).val >> 11)

#define __swp_entry(type, offset) \
((swp_entry_t) { ((type) << 4) | ((offset) << 11) })
((swp_entry_t) { ((type) << 5) | ((offset) << 11) })
#define __pte_to_swp_entry(pte) \
((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
Expand Down
2 changes: 1 addition & 1 deletion arch/um/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ static inline struct thread_info *current_thread_info(void)
#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
#define TIF_SYSCALL_AUDIT 6
#define TIF_RESTORE_SIGMASK 7
#define TIF_NOTIFY_RESUME 8

#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
#define _TIF_MEMDIE (1 << TIF_MEMDIE)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)

#endif
2 changes: 1 addition & 1 deletion arch/um/include/shared/irq_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ extern int um_request_irq(unsigned int irq, int fd, int type,
irq_handler_t handler,
unsigned long irqflags, const char * devname,
void *dev_id);

void um_free_irq(unsigned int irq, void *dev);
#endif

9 changes: 7 additions & 2 deletions arch/um/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ unsigned int do_IRQ(int irq, struct uml_pt_regs *regs)
return 1;
}

void um_free_irq(unsigned int irq, void *dev)
{
free_irq_by_irq_and_dev(irq, dev);
free_irq(irq, dev);
}
EXPORT_SYMBOL(um_free_irq);

int um_request_irq(unsigned int irq, int fd, int type,
irq_handler_t handler,
unsigned long irqflags, const char * devname,
Expand Down Expand Up @@ -327,15 +334,13 @@ static void dummy(struct irq_data *d)
/* This is used for everything else than the timer. */
static struct irq_chip normal_irq_type = {
.name = "SIGIO",
.release = free_irq_by_irq_and_dev,
.irq_disable = dummy,
.irq_enable = dummy,
.irq_ack = dummy,
};

static struct irq_chip SIGVTALRM_irq_type = {
.name = "SIGVTALRM",
.release = free_irq_by_irq_and_dev,
.irq_disable = dummy,
.irq_enable = dummy,
.irq_ack = dummy,
Expand Down
10 changes: 8 additions & 2 deletions arch/um/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/seq_file.h>
#include <linux/tick.h>
#include <linux/threads.h>
#include <linux/tracehook.h>
#include <asm/current.h>
#include <asm/pgtable.h>
#include <asm/mmu_context.h>
Expand Down Expand Up @@ -114,8 +115,13 @@ void interrupt_end(void)
{
if (need_resched())
schedule();
if (test_tsk_thread_flag(current, TIF_SIGPENDING))
if (test_thread_flag(TIF_SIGPENDING))
do_signal();
if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME)) {
tracehook_notify_resume(&current->thread.regs);
if (current->replacement_session_keyring)
key_replace_session_keyring();
}
}

void exit_thread(void)
Expand Down Expand Up @@ -190,7 +196,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
if (current->thread.forking) {
memcpy(&p->thread.regs.regs, &regs->regs,
sizeof(p->thread.regs.regs));
REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.gp, 0);
UPT_SET_SYSCALL_RETURN(&p->thread.regs.regs, 0);
if (sp != 0)
REGS_SP(p->thread.regs.regs.gp) = sp;

Expand Down
14 changes: 5 additions & 9 deletions arch/um/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
unsigned long sp;
int err;

/* Always make any pending restarted system calls return -EINTR */
current_thread_info()->restart_block.fn = do_no_restart_syscall;

/* Did we come from a system call? */
if (PT_REGS_SYSCALL_NR(regs) >= 0) {
/* If so, check system call restarting.. */
Expand Down Expand Up @@ -77,15 +74,14 @@ static int kern_do_signal(struct pt_regs *regs)
{
struct k_sigaction ka_copy;
siginfo_t info;
sigset_t *oldset;
int sig, handled_sig = 0;

if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
sigset_t *oldset;
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;
handled_sig = 1;
/* Whee! Actually deliver the signal. */
if (!handle_signal(regs, sig, &ka_copy, &info, oldset)) {
Expand Down
2 changes: 1 addition & 1 deletion arch/um/kernel/skas/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void handle_syscall(struct uml_pt_regs *r)
result = -ENOSYS;
else result = EXECUTE_SYSCALL(syscall, regs);

REGS_SET_SYSCALL_RETURN(r->gp, result);
UPT_SET_SYSCALL_RETURN(r, result);

syscall_trace(r, 1);
}
1 change: 1 addition & 0 deletions arch/um/kernel/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static int do_ops(struct host_vm_change *hvc, int end,
default:
printk(KERN_ERR "Unknown op type %d in do_ops\n",
op->type);
BUG();
break;
}
}
Expand Down
10 changes: 0 additions & 10 deletions arch/um/os-Linux/skas/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ __initcall(init_syscall_regs);

extern int proc_mm;

int single_count = 0;
int multi_count = 0;
int multi_op_count = 0;

static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
{
int n, i;
Expand All @@ -64,8 +60,6 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
/* FIXME: Need to look up userspace_pid by cpu */
pid = userspace_pid[0];

multi_count++;

n = ptrace_setregs(pid, syscall_regs);
if (n < 0) {
printk(UM_KERN_ERR "Registers - \n");
Expand Down Expand Up @@ -126,9 +120,6 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall,
{
unsigned long *stack = check_init_stack(mm_idp, *addr);

if (done && *addr == NULL)
single_count++;

*stack += sizeof(long);
stack += *stack / sizeof(long);

Expand All @@ -141,7 +132,6 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall,
*stack++ = args[5];
*stack++ = expected;
*stack = 0;
multi_op_count++;

if (!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) <
UM_KERN_PAGE_SIZE - 10 * sizeof(long))) {
Expand Down
42 changes: 21 additions & 21 deletions arch/x86/um/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
#define ELF_ARCH EM_386

#define ELF_PLAT_INIT(regs, load_addr) do { \
PT_REGS_EBX(regs) = 0; \
PT_REGS_ECX(regs) = 0; \
PT_REGS_EDX(regs) = 0; \
PT_REGS_ESI(regs) = 0; \
PT_REGS_EDI(regs) = 0; \
PT_REGS_EBP(regs) = 0; \
PT_REGS_EAX(regs) = 0; \
PT_REGS_BX(regs) = 0; \
PT_REGS_CX(regs) = 0; \
PT_REGS_DX(regs) = 0; \
PT_REGS_SI(regs) = 0; \
PT_REGS_DI(regs) = 0; \
PT_REGS_BP(regs) = 0; \
PT_REGS_AX(regs) = 0; \
} while (0)

/* Shamelessly stolen from include/asm-i386/elf.h */

#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
pr_reg[0] = PT_REGS_EBX(regs); \
pr_reg[1] = PT_REGS_ECX(regs); \
pr_reg[2] = PT_REGS_EDX(regs); \
pr_reg[3] = PT_REGS_ESI(regs); \
pr_reg[4] = PT_REGS_EDI(regs); \
pr_reg[5] = PT_REGS_EBP(regs); \
pr_reg[6] = PT_REGS_EAX(regs); \
pr_reg[0] = PT_REGS_BX(regs); \
pr_reg[1] = PT_REGS_CX(regs); \
pr_reg[2] = PT_REGS_DX(regs); \
pr_reg[3] = PT_REGS_SI(regs); \
pr_reg[4] = PT_REGS_DI(regs); \
pr_reg[5] = PT_REGS_BP(regs); \
pr_reg[6] = PT_REGS_AX(regs); \
pr_reg[7] = PT_REGS_DS(regs); \
pr_reg[8] = PT_REGS_ES(regs); \
/* fake once used fs and gs selectors? */ \
Expand Down Expand Up @@ -130,13 +130,13 @@ do { \
#define ELF_ARCH EM_X86_64

#define ELF_PLAT_INIT(regs, load_addr) do { \
PT_REGS_RBX(regs) = 0; \
PT_REGS_RCX(regs) = 0; \
PT_REGS_RDX(regs) = 0; \
PT_REGS_RSI(regs) = 0; \
PT_REGS_RDI(regs) = 0; \
PT_REGS_RBP(regs) = 0; \
PT_REGS_RAX(regs) = 0; \
PT_REGS_BX(regs) = 0; \
PT_REGS_CX(regs) = 0; \
PT_REGS_DX(regs) = 0; \
PT_REGS_SI(regs) = 0; \
PT_REGS_DI(regs) = 0; \
PT_REGS_BP(regs) = 0; \
PT_REGS_AX(regs) = 0; \
PT_REGS_R8(regs) = 0; \
PT_REGS_R9(regs) = 0; \
PT_REGS_R10(regs) = 0; \
Expand Down
34 changes: 34 additions & 0 deletions arch/x86/um/asm/ptrace.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
#ifndef __UM_X86_PTRACE_H
#define __UM_X86_PTRACE_H

#ifdef CONFIG_X86_32
# include "ptrace_32.h"
#else
# include "ptrace_64.h"
#endif

#define PT_REGS_AX(r) UPT_AX(&(r)->regs)
#define PT_REGS_BX(r) UPT_BX(&(r)->regs)
#define PT_REGS_CX(r) UPT_CX(&(r)->regs)
#define PT_REGS_DX(r) UPT_DX(&(r)->regs)

#define PT_REGS_SI(r) UPT_SI(&(r)->regs)
#define PT_REGS_DI(r) UPT_DI(&(r)->regs)
#define PT_REGS_BP(r) UPT_BP(&(r)->regs)
#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)

#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
#define PT_REGS_ES(r) UPT_ES(&(r)->regs)

#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_AX(r)
#define PT_REGS_SYSCALL_RET(r) PT_REGS_AX(r)

#define PT_FIX_EXEC_STACK(sp) do ; while(0)

#define profile_pc(regs) PT_REGS_IP(regs)

#define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
#define UPT_SET_SYSCALL_RETURN(r, res) (UPT_AX(r) = (res))

static inline long regs_return_value(struct uml_pt_regs *regs)
{
return UPT_AX(regs);
}
#endif /* __UM_X86_PTRACE_H */
Loading

0 comments on commit 3a8580f

Please sign in to comment.