[CRIU] [PATCH 3/9] cr: introduced the macro P() to convert an integer to unsigned long

Stanislav Kinsbursky skinsbursky at parallels.com
Wed Jan 16 03:31:16 EST 2013


Any comment to this patch?

16.01.2013 12:28, Alexander Kartashov пишет:
>
> Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
> ---
>   arch/x86/include/asm/types.h |    2 ++
>   cr-dump.c                    |    2 +-
>   cr-restore.c                 |   12 ++++++------
>   parasite-syscall.c           |    6 +++---
>   pie/parasite.c               |    4 ++--
>   pie/restorer.c               |   12 ++++++------
>   pipes.c                      |    2 +-
>   sk-inet.c                    |    4 ++--
>   sk-packet.c                  |    2 +-
>   util.c                       |    4 ++--
>   10 files changed, 26 insertions(+), 24 deletions(-)
>
> diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
> index 837daa8..75e256c 100644
> --- a/arch/x86/include/asm/types.h
> +++ b/arch/x86/include/asm/types.h
> @@ -280,4 +280,6 @@ typedef struct {
>
>   typedef UserX86RegsEntry UserRegsEntry;
>
> +#define P(i) i
> +
>   #endif /* __CR_ASM_TYPES_H__ */
> diff --git a/cr-dump.c b/cr-dump.c
> index 4a1e9e9..aeea461 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -658,7 +658,7 @@ static int get_task_futex_robust_list(pid_t pid, ThreadCoreEntry *info)
>   		return -1;
>   	}
>
> -	info->futex_rla		= (u64)head;
> +	info->futex_rla		= (u64)P(head);
>   	info->futex_rla_len	= (u32)len;
>
>   	return 0;
> diff --git a/cr-restore.c b/cr-restore.c
> index b4e489a..c262c73 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -217,7 +217,7 @@ static int map_private_vma(pid_t pid, struct vma_area *vma, void *tgt_addr,
>   		    p->vma.start == vma->vma.start) {
>   			pr_info("COW 0x%016lx-0x%016lx 0x%016lx vma\n",
>   				vma->vma.start, vma->vma.end, vma->vma.pgoff);
> -			paddr = (void *) vma_premmaped_start(&p->vma);
> +			paddr = (void *)P(vma_premmaped_start(&p->vma));
>   			break;
>   		}
>
> @@ -309,8 +309,8 @@ static int restore_priv_vma_content(pid_t pid)
>   			return -1;
>   		}
>
> -		p = (void *) (va - vma->vma.start +
> -					vma_premmaped_start(&vma->vma));
> +		p = (void *) (va - P(vma->vma.start) +
> +					P(vma_premmaped_start(&vma->vma)));
>   		if (memcmp(p, buf, PAGE_SIZE) == 0) {
>   			nr_shared++;
>   			continue;
> @@ -324,7 +324,7 @@ static int restore_priv_vma_content(pid_t pid)
>   	/* Remove pages, which were not shared with a child */
>   	list_for_each_entry(vma, &rst_vma_list, list) {
>   		unsigned long size, i = 0;
> -		void *addr = (void *) vma_premmaped_start(&vma->vma);
> +		void *addr = (void *) P(vma_premmaped_start(&vma->vma));
>
>   		if (vma->ppage_bitmap == NULL)
>   			continue;
> @@ -529,9 +529,9 @@ static int prepare_sigactions(int pid)
>   		if (ret < 0)
>   			break;
>
> -		ASSIGN_TYPED(act.rt_sa_handler, e->sigaction);
> +		ASSIGN_TYPED(act.rt_sa_handler, P(e->sigaction));
>   		ASSIGN_TYPED(act.rt_sa_flags, e->flags);
> -		ASSIGN_TYPED(act.rt_sa_restorer, e->restorer);
> +		ASSIGN_TYPED(act.rt_sa_restorer, P(e->restorer));
>   		ASSIGN_TYPED(act.rt_sa_mask.sig[0], e->mask);
>
>   		sa_entry__free_unpacked(e, NULL);
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index af71878..33a58da 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -362,7 +362,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, struct pid *tid,
>   	ret = parasite_execute_by_pid(PARASITE_CMD_DUMP_THREAD, ctl, tid->real);
>
>   	memcpy(&core->thread_core->blk_sigset, &args->blocked, sizeof(args->blocked));
> -	CORE_THREAD_ARCH_INFO(core)->clear_tid_addr = (u64)args->tid_addr;
> +	CORE_THREAD_ARCH_INFO(core)->clear_tid_addr = (u64)P(args->tid_addr);
>   	tid->virt = args->tid;
>   	core_put_tls(core, args->tls);
>
> @@ -389,9 +389,9 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
>   		if (sig == SIGSTOP || sig == SIGKILL)
>   			continue;
>
> -		ASSIGN_TYPED(se.sigaction, args->sas[i].rt_sa_handler);
> +		ASSIGN_TYPED(se.sigaction, P(args->sas[i].rt_sa_handler));
>   		ASSIGN_TYPED(se.flags, args->sas[i].rt_sa_flags);
> -		ASSIGN_TYPED(se.restorer, args->sas[i].rt_sa_restorer);
> +		ASSIGN_TYPED(se.restorer, P(args->sas[i].rt_sa_restorer));
>   		ASSIGN_TYPED(se.mask, args->sas[i].rt_sa_mask.sig[0]);
>
>   		if (pb_write_one(fd, &se, PB_SIGACT) < 0)
> diff --git a/pie/parasite.c b/pie/parasite.c
> index 3e444ea..4d98701 100644
> --- a/pie/parasite.c
> +++ b/pie/parasite.c
> @@ -179,7 +179,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
>   	if (!(args->vma_entry.prot & PROT_READ)) {
>   		prot_old = (unsigned long)args->vma_entry.prot;
>   		prot_new = prot_old | PROT_READ;
> -		ret = sys_mprotect((void *)args->vma_entry.start,
> +		ret = sys_mprotect((void *)P(args->vma_entry.start),
>   				   (unsigned long)vma_entry_len(&args->vma_entry),
>   				   prot_new);
>   		if (ret) {
> @@ -215,7 +215,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
>   	 * Don't left pages readable if they were not.
>   	 */
>   	if (prot_old != prot_new) {
> -		ret = sys_mprotect((void *)args->vma_entry.start,
> +		ret = sys_mprotect((void *)P(args->vma_entry.start),
>   				   (unsigned long)vma_entry_len(&args->vma_entry),
>   				   prot_old);
>   		if (ret) {
> diff --git a/pie/restorer.c b/pie/restorer.c
> index c01fce1..76b7371 100644
> --- a/pie/restorer.c
> +++ b/pie/restorer.c
> @@ -154,10 +154,10 @@ static void restore_rlims(struct task_restore_core_args *ta)
>   static int restore_thread_common(struct rt_sigframe *sigframe,
>   		struct thread_restore_args *args)
>   {
> -	sys_set_tid_address((int *)args->clear_tid_addr);
> +	sys_set_tid_address((int *)P(args->clear_tid_addr));
>
>   	if (args->has_futex) {
> -		if (sys_set_robust_list((void *)args->futex_rla, args->futex_rla_len)) {
> +		if (sys_set_robust_list((void *)P(args->futex_rla), args->futex_rla_len)) {
>   			pr_err("Robust list err\n");
>   			return -1;
>   		}
> @@ -238,7 +238,7 @@ static u64 restore_mapping(const VmaEntry *vma_entry)
>   	u64 addr;
>
>   	if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC))
> -		return sys_shmat(vma_entry->fd, (void *)vma_entry->start,
> +		return sys_shmat(vma_entry->fd, (void *)P(vma_entry->start),
>   				 (vma_entry->prot & PROT_WRITE) ? 0 : SHM_RDONLY);
>
>   	/*
> @@ -255,14 +255,14 @@ static u64 restore_mapping(const VmaEntry *vma_entry)
>   		prot |= PROT_WRITE;
>
>   	pr_debug("\tmmap(%lx -> %lx, %x %x %d\n",
> -			vma_entry->start, vma_entry->end,
> +			P(vma_entry->start), P(vma_entry->end),
>   			prot, flags, (int)vma_entry->fd);
>   	/*
>   	 * Should map memory here. Note we map them as
>   	 * writable since we're going to restore page
>   	 * contents.
>   	 */
> -	addr = sys_mmap((void *)vma_entry->start,
> +	addr = sys_mmap((void *)P(vma_entry->start),
>   			vma_entry_len(vma_entry),
>   			prot, flags,
>   			vma_entry->fd,
> @@ -518,7 +518,7 @@ long __export_restore_task(struct task_restore_core_args *args)
>   		if (vma_entry->prot & PROT_WRITE)
>   			continue;
>
> -		sys_mprotect((void *)vma_entry->start,
> +		sys_mprotect((void *)P(vma_entry->start),
>   			     vma_entry_len(vma_entry),
>   			     vma_entry->prot);
>   	}
> diff --git a/pipes.c b/pipes.c
> index 16a2454..8b801b8 100644
> --- a/pipes.c
> +++ b/pipes.c
> @@ -186,7 +186,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
>
>   		if (ret == 0 || ret > iov.iov_len /* sanity */) {
>   			pr_err("%#x: Wanted to restore %lu bytes, but got %d\n", id,
> -					iov.iov_len, ret);
> +					P(iov.iov_len), ret);
>   			ret = -1;
>   			goto err;
>   		}
> diff --git a/sk-inet.c b/sk-inet.c
> index f8b47c0..5a65101 100644
> --- a/sk-inet.c
> +++ b/sk-inet.c
> @@ -426,8 +426,8 @@ static int inet_validate_address(InetSkEntry *ie)
>   		return 0;
>
>   	pr_err("Addr len mismatch f %d ss %lu ds %lu\n", ie->family,
> -			pb_repeated_size(ie, src_addr),
> -			pb_repeated_size(ie, dst_addr));
> +			P(pb_repeated_size(ie, src_addr)),
> +			P(pb_repeated_size(ie, dst_addr)));
>
>   	return -1;
>   }
> diff --git a/sk-packet.c b/sk-packet.c
> index 9b667c4..e05caa3 100644
> --- a/sk-packet.c
> +++ b/sk-packet.c
> @@ -344,7 +344,7 @@ static int restore_mreqs(int sk, PacketSockEntry *pse)
>   		pr_info("Restoring mreq type %d\n", ml->type);
>
>   		if (ml->addr.len > sizeof(mreq.mr_address)) {
> -			pr_err("To big mcaddr %lu\n", ml->addr.len);
> +			pr_err("To big mcaddr %lu\n", P(ml->addr.len));
>   			return -1;
>   		}
>
> diff --git a/util.c b/util.c
> index 93678d2..ca7de97 100644
> --- a/util.c
> +++ b/util.c
> @@ -388,7 +388,7 @@ int copy_file(int fd_in, int fd_out, size_t bytes)
>   		if (ret == 0) {
>   			if (bytes && (written != bytes)) {
>   				pr_err("Ghost file size mismatch %lu/%lu\n",
> -						written, bytes);
> +						P(written), P(bytes));
>   				return -1;
>   			}
>   			break;
> @@ -435,7 +435,7 @@ void *shmalloc(size_t bytes)
>   	void *ret;
>
>   	if (bytes > SH_BUF_CHUNK) {
> -		pr_err("Too big shared buffer requested %lu\n", bytes);
> +		pr_err("Too big shared buffer requested %lu\n", P(bytes));
>   		return NULL;
>   	}
>
>


-- 
Best regards,
Stanislav Kinsbursky


More information about the CRIU mailing list