[PATCH] netfilter: ipvs: Fix space before '[' error.

2017-07-30 Thread Arvind Yadav
Fix checkpatch.pl error:
ERROR: space prohibited before open square bracket '['.

Signed-off-by: Arvind Yadav 
---
 net/netfilter/ipvs/ip_vs_proto_tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c 
b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index 12dc8d5..4fc17fc 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -439,7 +439,7 @@ static bool tcp_state_active(int state)
return tcp_state_active_table[state];
 }
 
-static struct tcp_states_t tcp_states [] = {
+static struct tcp_states_t tcp_states[] = {
 /* INPUT */
 /*sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA*/
 /*syn*/ {{sSR, sES, sES, sSR, sSR, sSR, sSR, sSR, sSR, sSR, sSR }},
@@ -462,7 +462,7 @@ static struct tcp_states_t tcp_states [] = {
 /*rst*/ {{sCL, sCL, sCL, sSR, sCL, sCL, sCL, sCL, sLA, sLI, sCL }},
 };
 
-static struct tcp_states_t tcp_states_dos [] = {
+static struct tcp_states_t tcp_states_dos[] = {
 /* INPUT */
 /*sNO, sES, sSS, sSR, sFW, sTW, sCL, sCW, sLA, sLI, sSA*/
 /*syn*/ {{sSR, sES, sES, sSR, sSR, sSR, sSR, sSR, sSR, sSR, sSA }},
-- 
2.7.4



[PATCH] userfaultfd: non-cooperative: flush event_wqh at release time

2017-07-30 Thread Mike Rapoport
There maybe still threads waiting on event_wqh at the time the userfault
file descriptor is closed. Flush the events wait-queue to prevent waiting
threads from hanging.

Cc: sta...@vger.kernel.org
Fixes: 9cd75c3cd4c3d ("userfaultfd: non-cooperative: add ability to report
non-PF events from uffd descriptor")

Signed-off-by: Mike Rapoport 
---
 fs/userfaultfd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 2d8c2d848668..06ea26b8c996 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -854,6 +854,9 @@ static int userfaultfd_release(struct inode *inode, struct 
file *file)
__wake_up_locked_key(&ctx->fault_wqh, TASK_NORMAL, &range);
spin_unlock(&ctx->fault_pending_wqh.lock);
 
+   /* Flush pending events that may still wait on event_wqh */
+   wake_up_all(&ctx->event_wqh);
+
wake_up_poll(&ctx->fd_wqh, POLLHUP);
userfaultfd_ctx_put(ctx);
return 0;
-- 
2.7.4



Re: [PATCH v2 2/2] userfaultfd: selftest: Add tests for UFFD_FEATURE_SIGBUS feature

2017-07-30 Thread Mike Rapoport
On Thu, Jul 27, 2017 at 10:18:40PM -0400, Prakash Sangappa wrote:
> This patch adds tests for UFFD_FEATURE_SIGBUS feature. The
> tests will verify signal delivery instead of userfault events.
> Also, test use of UFFDIO_COPY to allocate memory and retry
> accessing monitored area after signal delivery.
> 
> This patch also fixes a bug in uffd_poll_thread() where 'uffd'
> is leaked.
> 
> Signed-off-by: Prakash Sangappa 
> ---
> Change log
> 
> v2:
>   - Added comments to explain the tests.
>   - Fixed test to fail immediately if signal repeats.
>   - Addressed other review comments.
> 
> v1: https://lkml.org/lkml/2017/7/26/101
> ---

Overall looks good to me, just small nitpick below.

>  tools/testing/selftests/vm/userfaultfd.c |  127 
> +-
>  1 files changed, 124 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/vm/userfaultfd.c 
> b/tools/testing/selftests/vm/userfaultfd.c
> index 1eae79a..3976d7a 100644
> --- a/tools/testing/selftests/vm/userfaultfd.c
> +++ b/tools/testing/selftests/vm/userfaultfd.c
> @@ -66,6 +66,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #ifdef __NR_userfaultfd
> 
> @@ -408,6 +409,7 @@ static int copy_page(int ufd, unsigned long offset)
>   userfaults++;
>   break;
>   case UFFD_EVENT_FORK:
> + close(uffd);
>   uffd = msg.arg.fork.ufd;
>   pollfd[0].fd = uffd;
>   break;
> @@ -572,6 +574,17 @@ static int userfaultfd_open(int features)
>   return 0;
>  }
> 
> +sigjmp_buf jbuf, *sigbuf;
> +
> +static void sighndl(int sig, siginfo_t *siginfo, void *ptr)
> +{
> + if (sig == SIGBUS) {
> + if (sigbuf)
> + siglongjmp(*sigbuf, 1);
> + abort();
> + }
> +}
> +
>  /*
>   * For non-cooperative userfaultfd test we fork() a process that will
>   * generate pagefaults, will mremap the area monitored by the
> @@ -585,19 +598,59 @@ static int userfaultfd_open(int features)
>   * The release of the pages currently generates event for shmem and
>   * anonymous memory (UFFD_EVENT_REMOVE), hence it is not checked
>   * for hugetlb.
> + * For signal test(UFFD_FEATURE_SIGBUS), signal_test = 1, we register
> + * monitored area, generate pagefaults and test that signal is delivered.
> + * Use UFFDIO_COPY to allocate missing page and retry. For signal_test = 2
> + * test robustness use case - we release monitored area, fork a process
> + * that will generate pagefaults and verify signal is generated.
> + * This also tests UFFD_FEATURE_EVENT_FORK event along with the signal
> + * feature. Using monitor thread, verify no userfault events are generated.
>   */
> -static int faulting_process(void)
> +static int faulting_process(int signal_test)
>  {
>   unsigned long nr;
>   unsigned long long count;
>   unsigned long split_nr_pages;
> + unsigned long lastnr;
> + struct sigaction act;
> + unsigned long signalled = 0, sig_repeats = 0;
> 
>   if (test_type != TEST_HUGETLB)
>   split_nr_pages = (nr_pages + 1) / 2;
>   else
>   split_nr_pages = nr_pages;
> 
> + if (signal_test) {
> + sigbuf = &jbuf;
> + memset(&act, 0, sizeof(act));
> + act.sa_sigaction = sighndl;
> + act.sa_flags = SA_SIGINFO;
> + if (sigaction(SIGBUS, &act, 0)) {
> + perror("sigaction");
> + return 1;
> + }
> + lastnr = (unsigned long)-1;
> + }
> +
>   for (nr = 0; nr < split_nr_pages; nr++) {
> + if (signal_test) {
> + if (sigsetjmp(*sigbuf, 1) != 0) {
> + if (nr == lastnr) {
> + sig_repeats++;

You can simply 'return 1' here, then sig_repeats variable can be dropped
and the return statement for signal_test can be simplified.

> + break;
> + }
> +
> + lastnr = nr;
> + if (signal_test == 1) {
> + if (copy_page(uffd, nr * page_size))
> + signalled++;
> + } else {
> + signalled++;
> + continue;
> + }
> + }
> + }
> +
>   count = *area_count(area_dst, nr);
>   if (count != count_verify[nr]) {
>   fprintf(stderr,
> @@ -607,6 +660,9 @@ static int faulting_process(void)
>   }
>   }
> 
> + if (signal_test)
> + return !(signalled == split_nr_pages && sig_repeats == 0);
> +
>   if (test_type == TEST_HUGETLB)
>   return 0;
> 
> @@ -761,7 +817,7 @@ static int userfaultfd_even

Re: Yes you have standing to sue GRSecurity

2017-07-30 Thread David C. Rankin
On 07/30/2017 12:55 AM, David Lang wrote:
> You are thinking of Trademarks, they must be defended or you loose them.
> Contracts and Licenses do not need to be defended at every chance or risk
> loosing them.

No, not always, it can apply in plain contract as well. The defenses that
could be later raised by grsecurity if this issue goes unaddressed is are (1)
latches; and (2) waiver. It is a slippery slope. While, without commenting on
the dubious nature of the current use of the defenses (as catch-all,
kitchen-sink affirmative-defenses), they can be expected to be raised if
rights under GPL to insure no further restrictions are placed on subsequent
use of the kernel-code are not enforced.

I hope there is a centralized forum that will be established for this issue
(there may be and I'm just not smart enough to have found it yet). Certainly,
if for nothing else, so the advantages and disadvantages of both action, and
inaction, can be peer-reviewed on both the legal and technical side.

-- 
David C. Rankin, J.D.,P.E.


Re: [PATCH] f2fs: provide f2fs_balance_fs to __write_data_page for dentry pages

2017-07-30 Thread kbuild test robot
Hi Yunlong,

[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on v4.13-rc2 next-20170728]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Yunlong-Song/f2fs-provide-f2fs_balance_fs-to-__write_data_page-for-dentry-pages/20170730-141454
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git 
dev-test
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "__inode_attach_wb" [fs/f2fs/f2fs.ko] undefined!
>> ERROR: "wbc_attach_and_unlock_inode" [fs/f2fs/f2fs.ko] undefined!
>> ERROR: "wbc_detach_inode" [fs/f2fs/f2fs.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] f2fs: provide f2fs_balance_fs to __write_data_page for dentry pages

2017-07-30 Thread Jaegeuk Kim
On 07/29, Yunlong Song wrote:
> f2fs_balance_fs of dentry pages is skipped in __write_data_page due to 
> deadlock
> of gc_mutex in write_checkpoint flow. This patch enables f2fs_balance_fs for
> normal dentry page writeback to ensure there are always enough free segments.

Sorry, by the way, why do we need to do this? I subtly thought that dirty node
pages can be produce by redirtied inodes from what we've not covered through
filesystem calls. But, in dentry pages, we're controlling the number of dirty
pages, and calling f2fs_balance_fs in each directory operations.

Chao?

Thanks,

> 
> Reported-by: Chao Yu 
> Signed-off-by: Yunlong Song 
> ---
>  fs/f2fs/checkpoint.c |  2 +-
>  fs/f2fs/data.c   | 67 
> +---
>  fs/f2fs/f2fs.h   |  1 +
>  3 files changed, 61 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 3c84a25..2882878 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -904,7 +904,7 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum 
> inode_type type)
>   if (inode) {
>   unsigned long cur_ino = inode->i_ino;
>  
> - filemap_fdatawrite(inode->i_mapping);
> + f2fs_filemap_fdatawrite(inode->i_mapping, is_dir);
>   iput(inode);
>   /* We need to give cpu to another writers. */
>   if (ino == cur_ino) {
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index aefc2a5..ed7efa5 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1475,7 +1475,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
>  }
>  
>  static int __write_data_page(struct page *page, bool *submitted,
> - struct writeback_control *wbc)
> + struct writeback_control *wbc, bool do_balance)
>  {
>   struct inode *inode = page->mapping->host;
>   struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> @@ -1578,7 +1578,7 @@ static int __write_data_page(struct page *page, bool 
> *submitted,
>   }
>  
>   unlock_page(page);
> - if (!S_ISDIR(inode->i_mode))
> + if (do_balance)
>   f2fs_balance_fs(sbi, need_balance_fs);
>  
>   if (unlikely(f2fs_cp_error(sbi))) {
> @@ -1602,7 +1602,7 @@ static int __write_data_page(struct page *page, bool 
> *submitted,
>  static int f2fs_write_data_page(struct page *page,
>   struct writeback_control *wbc)
>  {
> - return __write_data_page(page, NULL, wbc);
> + return __write_data_page(page, NULL, wbc, true);
>  }
>  
>  /*
> @@ -1611,7 +1611,7 @@ static int f2fs_write_data_page(struct page *page,
>   * warm/hot data page.
>   */
>  static int f2fs_write_cache_pages(struct address_space *mapping,
> - struct writeback_control *wbc)
> + struct writeback_control *wbc, bool 
> do_balance)
>  {
>   int ret = 0;
>   int done = 0;
> @@ -1701,7 +1701,7 @@ static int f2fs_write_cache_pages(struct address_space 
> *mapping,
>   if (!clear_page_dirty_for_io(page))
>   goto continue_unlock;
>  
> - ret = __write_data_page(page, &submitted, wbc);
> + ret = __write_data_page(page, &submitted, wbc, 
> do_balance);
>   if (unlikely(ret)) {
>   /*
>* keep nr_to_write, since vfs uses this to
> @@ -1756,8 +1756,8 @@ static int f2fs_write_cache_pages(struct address_space 
> *mapping,
>   return ret;
>  }
>  
> -static int f2fs_write_data_pages(struct address_space *mapping,
> - struct writeback_control *wbc)
> +static int _f2fs_write_data_pages(struct address_space *mapping,
> + struct writeback_control *wbc, bool do_balance)
>  {
>   struct inode *inode = mapping->host;
>   struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> @@ -1794,7 +1794,7 @@ static int f2fs_write_data_pages(struct address_space 
> *mapping,
>   goto skip_write;
>  
>   blk_start_plug(&plug);
> - ret = f2fs_write_cache_pages(mapping, wbc);
> + ret = f2fs_write_cache_pages(mapping, wbc, do_balance);
>   blk_finish_plug(&plug);
>  
>   if (wbc->sync_mode == WB_SYNC_ALL)
> @@ -1813,6 +1813,57 @@ static int f2fs_write_data_pages(struct address_space 
> *mapping,
>   return 0;
>  }
>  
> +static int f2fs_write_data_pages(struct address_space *mapping,
> + struct writeback_control *wbc)
> +{
> + return  _f2fs_write_data_pages(mapping, wbc, true);
> +}
> +
> +/*
> + * This function was copied from do_writepages from mm/page-writeback.c.
> + * The major change is changing writepages to _f2fs_write_data_pages.
> + */
> +static int f2fs_do_writepages(struct address_space *mapping,
> + struct writeback_control *wbc, bool is_dir)
> +{
> + int r

[PATCH] KVM: nVMX: Fix try to emulate "Acknowledge interrupt on exit" for interrupt which belongs to L1

2017-07-30 Thread Wanpeng Li
From: Wanpeng Li 

[ cut here ]
 WARNING: CPU: 5 PID: 2288 at arch/x86/kvm/vmx.c:11124 
nested_vmx_vmexit+0xd64/0xd70 [kvm_intel]
 CPU: 5 PID: 2288 Comm: qemu-system-x86 Not tainted 4.13.0-rc2+ #7
 RIP: 0010:nested_vmx_vmexit+0xd64/0xd70 [kvm_intel]
Call Trace:
  vmx_check_nested_events+0x131/0x1f0 [kvm_intel]
  ? vmx_check_nested_events+0x131/0x1f0 [kvm_intel]
  kvm_arch_vcpu_ioctl_run+0x5dd/0x1be0 [kvm]
  ? vmx_vcpu_load+0x1be/0x220 [kvm_intel]
  ? kvm_arch_vcpu_load+0x62/0x230 [kvm]
  kvm_vcpu_ioctl+0x340/0x700 [kvm]
  ? kvm_vcpu_ioctl+0x340/0x700 [kvm]
  ? __fget+0xfc/0x210
  do_vfs_ioctl+0xa4/0x6a0
  ? __fget+0x11d/0x210
  SyS_ioctl+0x79/0x90
  do_syscall_64+0x8f/0x750
  ? trace_hardirqs_on_thunk+0x1a/0x1c
  entry_SYSCALL64_slow_path+0x25/0x25

This can be reproduced by booting L1 guest w/ 'noapic' grub parameter, which 
means that tells the kernel to not make use of any IOAPICs that may be present 
in the system.

There is a scenario when !kvm_cpu_has_interrupt(vcpu) && external_intr in 
vmx_check_nested_events() which means that there is a pending interrupt from 
L0's qemu device model which should be injected to L1, we should not try to 
emualte "Acknowledge interrupt on exit" for this interrupt.

This patch fixes it by trying to emulate "Acknowledge interrupt on exit" if L1 
asks us to.

Cc: Paolo Bonzini 
Cc: Radim Krčmář 
Signed-off-by: Wanpeng Li 
---
 arch/x86/kvm/vmx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2737343..92eb0f75 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -8,8 +8,9 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, 
u32 exit_reason,
 
vmx_switch_vmcs(vcpu, &vmx->vmcs01);
 
-   if ((exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT)
-   && nested_exit_intr_ack_set(vcpu)) {
+   if (exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT &&
+   kvm_cpu_has_interrupt(vcpu) &&
+   nested_exit_intr_ack_set(vcpu)) {
int irq = kvm_cpu_get_interrupt(vcpu);
WARN_ON(irq < 0);
vmcs12->vm_exit_intr_info = irq |
-- 
2.7.4



Re: [PATCH v2] f2fs: support journelled quota

2017-07-30 Thread Jaegeuk Kim
Hi Chao,

When I add this patch, xfstests/fsstress are giving some weird kernel hang
or panic now. Without only this patch, I can't see any problem. Can you review
this patch one more time in terms of memory and lock usages.

I'm doing xfstests without quota though.

Thanks,

On 07/26, Chao Yu wrote:
> From: Chao Yu 
> 
> This patch supports to enable f2fs to accept quota information through
> mount option:
> - {usr,grp,prj}jquota=
> - jqfmt=
> 
> Then, in ->mount flow, we can recover quota file during log replaying,
> by this, journelled quota can be supported.
> 
> Signed-off-by: Chao Yu 
> ---
> v2: fix warning in f2fs_remount.
>  Documentation/filesystems/f2fs.txt |   9 ++
>  fs/f2fs/f2fs.h |   7 +
>  fs/f2fs/recovery.c |  25 +++-
>  fs/f2fs/super.c| 284 
> +
>  4 files changed, 322 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/filesystems/f2fs.txt 
> b/Documentation/filesystems/f2fs.txt
> index b39d189c9677..b87067683297 100644
> --- a/Documentation/filesystems/f2fs.txt
> +++ b/Documentation/filesystems/f2fs.txt
> @@ -165,6 +165,15 @@ io_bits=%u Set the bit size of write IO 
> requests. It should be set
>  usrquota   Enable plain user disk quota accounting.
>  grpquota   Enable plain group disk quota accounting.
>  prjquota   Enable plain project quota accounting.
> +usrjquota=   Appoint specified file and type during mount, so that 
> quota
> +grpjquota=   information can be properly updated during recovery 
> flow,
> +prjjquota=   : must be in root directory;
> +jqfmt= : [vfsold,vfsv0,vfsv1].
> +offusrjquota   Turn off user journelled quota.
> +offgrpjquota   Turn off group journelled quota.
> +offprjjquota   Turn off project journelled quota.
> +quota  Enable plain user disk quota accounting.
> +noquotaDisable all plain disk quota option.
>  daxUse direct access (no page cache). See
> Documentation/filesystems/dax.txt.
>  
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index c57b83f7b108..a6259660e401 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -97,6 +97,7 @@ extern char *fault_name[FAULT_MAX];
>  #else
>  #define F2FS_MOUNT_DAX   0
>  #endif
> +#define F2FS_MOUNT_QUOTA 0x0080
>  
>  #define clear_opt(sbi, option)   ((sbi)->mount_opt.opt &= 
> ~F2FS_MOUNT_##option)
>  #define set_opt(sbi, option) ((sbi)->mount_opt.opt |= F2FS_MOUNT_##option)
> @@ -1100,6 +1101,12 @@ struct f2fs_sb_info {
>  #ifdef CONFIG_F2FS_FAULT_INJECTION
>   struct f2fs_fault_info fault_info;
>  #endif
> +
> +#ifdef CONFIG_QUOTA
> + /* Names of quota files with journalled quota */
> + char *s_qf_names[MAXQUOTAS];
> + int s_jquota_fmt;   /* Format of quota to use */
> +#endif
>  };
>  
>  #ifdef CONFIG_F2FS_FAULT_INJECTION
> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> index 2d9b8182691f..998568ec9b06 100644
> --- a/fs/f2fs/recovery.c
> +++ b/fs/f2fs/recovery.c
> @@ -69,20 +69,34 @@ static struct fsync_inode_entry *get_fsync_inode(struct 
> list_head *head,
>  }
>  
>  static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi,
> - struct list_head *head, nid_t ino)
> + struct list_head *head, nid_t ino, bool quota_inode)
>  {
>   struct inode *inode;
>   struct fsync_inode_entry *entry;
> + int err;
>  
>   inode = f2fs_iget_retry(sbi->sb, ino);
>   if (IS_ERR(inode))
>   return ERR_CAST(inode);
>  
> + err = dquot_initialize(inode);
> + if (err)
> + goto err_out;
> +
> + if (quota_inode) {
> + err = dquot_alloc_inode(inode);
> + if (err)
> + goto err_out;
> + }
> +
>   entry = f2fs_kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO);
>   entry->inode = inode;
>   list_add_tail(&entry->list, head);
>  
>   return entry;
> +err_out:
> + iput(inode);
> + return ERR_PTR(err);
>  }
>  
>  static void del_fsync_inode(struct fsync_inode_entry *entry)
> @@ -107,7 +121,8 @@ static int recover_dentry(struct inode *inode, struct 
> page *ipage,
>  
>   entry = get_fsync_inode(dir_list, pino);
>   if (!entry) {
> - entry = add_fsync_inode(F2FS_I_SB(inode), dir_list, pino);
> + entry = add_fsync_inode(F2FS_I_SB(inode), dir_list,
> + pino, false);
>   if (IS_ERR(entry)) {
>   dir = ERR_CAST(entry);
>   err = PTR_ERR(entry);
> @@ -226,18 +241,22 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, 
> struct list_head *head,
>  
>   entry = get_fsync_inode(head, ino_of_node(page));
>   if (!entry) {
> +  

Re: [RFC PATCH] f2fs: obsolete FI_ACL_MODE

2017-07-30 Thread Jaegeuk Kim
On 07/29, Chao Yu wrote:
> Hi Jaegeuk,
> 
> Could you take time to have a look at this? Is this change reasonable?
> 
> Thanks,
> 
> On 2017/7/26 22:33, Chao Yu wrote:
> > From: Chao Yu 
> > 
> > Previously, in order to avoid losing important inode metadata after
> > checkpoint & sudden power-off, f2fs uses synchronous approach for
> > updating inode metadata, so attribute in inode cache will be updated
> > to node page cache, after flushing dirty node pages in checkpoint,
> > these attribute in node page can be persisted.
> > 
> > However, f2fs has changed to use asynchronous inode metadata update
> > approach in commit 0f18b462b2e5 ("flush inode metadata when checkpoint
> > is doing"), with this change, we can obsolete synchrounous metadata
> > update approach including old acl updating method.>

Hmm, async doesn't mean guaranteed inode updates here, so it seems we can't
simply remove this still.

Thanks,

> > Signed-off-by: Chao Yu 
> > ---
> >  fs/f2fs/acl.c   |  8 +++-
> >  fs/f2fs/f2fs.h  | 13 -
> >  fs/f2fs/file.c  | 43 ---
> >  fs/f2fs/xattr.c |  6 +-
> >  4 files changed, 8 insertions(+), 62 deletions(-)
> > 
> > diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> > index b4b8438c42ef..25eaf243ee2e 100644
> > --- a/fs/f2fs/acl.c
> > +++ b/fs/f2fs/acl.c
> > @@ -215,7 +215,8 @@ static int __f2fs_set_acl(struct inode *inode, int type,
> > error = posix_acl_update_mode(inode, &inode->i_mode, 
> > &acl);
> > if (error)
> > return error;
> > -   set_acl_inode(inode, inode->i_mode);
> > +   inode->i_ctime = current_time(inode);
> > +   f2fs_mark_inode_dirty_sync(inode, true);
> > }
> > break;
> >  
> > @@ -231,10 +232,8 @@ static int __f2fs_set_acl(struct inode *inode, int 
> > type,
> >  
> > if (acl) {
> > value = f2fs_acl_to_disk(F2FS_I_SB(inode), acl, &size);
> > -   if (IS_ERR(value)) {
> > -   clear_inode_flag(inode, FI_ACL_MODE);
> > +   if (IS_ERR(value))
> > return PTR_ERR(value);
> > -   }
> > }
> >  
> > error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0);
> > @@ -243,7 +242,6 @@ static int __f2fs_set_acl(struct inode *inode, int type,
> > if (!error)
> > set_cached_acl(inode, type, acl);
> >  
> > -   clear_inode_flag(inode, FI_ACL_MODE);
> > return error;
> >  }
> >  
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 5cfffd6f0209..07a6697a0589 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -561,7 +561,6 @@ struct f2fs_inode_info {
> > unsigned char i_dir_level;  /* use for dentry level for large dir */
> > unsigned int i_current_depth;   /* use only in directory structure */
> > unsigned int i_pino;/* parent inode number */
> > -   umode_t i_acl_mode; /* keep file acl mode temporarily */
> >  
> > /* Use below internally in f2fs*/
> > unsigned long flags;/* use to pass per-file flags */
> > @@ -1957,7 +1956,6 @@ enum {
> > FI_AUTO_RECOVER,/* indicate inode is recoverable */
> > FI_DIRTY_DIR,   /* indicate directory has dirty pages */
> > FI_INC_LINK,/* need to increment i_nlink */
> > -   FI_ACL_MODE,/* indicate acl mode */
> > FI_NO_ALLOC,/* should not allocate any blocks */
> > FI_FREE_NID,/* free allocated nide */
> > FI_NO_EXTENT,   /* not to use the extent cache */
> > @@ -2016,13 +2014,6 @@ static inline void clear_inode_flag(struct inode 
> > *inode, int flag)
> > __mark_inode_dirty_flag(inode, flag, false);
> >  }
> >  
> > -static inline void set_acl_inode(struct inode *inode, umode_t mode)
> > -{
> > -   F2FS_I(inode)->i_acl_mode = mode;
> > -   set_inode_flag(inode, FI_ACL_MODE);
> > -   f2fs_mark_inode_dirty_sync(inode, false);
> > -}
> > -
> >  static inline void f2fs_i_links_write(struct inode *inode, bool inc)
> >  {
> > if (inc)
> > @@ -2295,10 +2286,6 @@ static inline int get_extra_isize(struct inode 
> > *inode)
> > return F2FS_I(inode)->i_extra_isize / sizeof(__le32);
> >  }
> >  
> > -#define get_inode_mode(i) \
> > -   ((is_inode_flag_set(i, FI_ACL_MODE)) ? \
> > -(F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
> > -
> >  #define F2FS_TOTAL_EXTRA_ATTR_SIZE \
> > (offsetof(struct f2fs_inode, i_extra_end) - \
> > offsetof(struct f2fs_inode, i_extra_isize)) \
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index e13f0ada1110..f8d3f4f928e7 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -763,36 +763,6 @@ int f2fs_getattr(const struct path *path, struct kstat 
> > *stat,
> > return 0;
> >  }
> >  
> > -#ifdef CONFIG_F2FS_FS_POSIX_ACL
> > -static void __setattr_copy(struct inode *inode, const struct iattr *attr)
> > -{
> > -  

drivers/clocksource/timer-of.h:35:28: error: field 'clkevt' has incomplete type

2017-07-30 Thread kbuild test robot
Hi Daniel,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0a07b238e5f488b459b6113a62e06b6aab017f71
commit: dc11bae78529526605c5c45c369c9512fd012093 clocksource/drivers: Add 
timer-of common init routine
date:   7 weeks ago
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout dc11bae78529526605c5c45c369c9512fd012093
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   In file included from drivers/clocksource/timer-of.c:25:0:
>> drivers/clocksource/timer-of.h:35:28: error: field 'clkevt' has incomplete 
>> type
 struct clock_event_device clkevt;
   ^~
   In file included from include/linux/clk.h:16:0,
from drivers/clocksource/timer-of.c:18:
   drivers/clocksource/timer-of.h: In function 'to_timer_of':
   include/linux/kernel.h:854:48: error: initialization from incompatible 
pointer type [-Werror=incompatible-pointer-types]
 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
   ^
   drivers/clocksource/timer-of.h:44:9: note: in expansion of macro 
'container_of'
 return container_of(clkevt, struct timer_of, clkevt);
^~~~
   drivers/clocksource/timer-of.c: In function 'timer_irq_init':
   drivers/clocksource/timer-of.c:63:8: error: dereferencing pointer to 
incomplete type 'struct clock_event_device'
 clkevt->irq = of_irq->irq;
   ^~
   cc1: some warnings being treated as errors

vim +/clkevt +35 drivers/clocksource/timer-of.h

32  
33  struct timer_of {
34  unsigned int flags;
  > 35  struct clock_event_device clkevt;
36  struct of_timer_base of_base;
37  struct of_timer_irq  of_irq;
38  struct of_timer_clk  of_clk;
39  void *private_data;
40  };
41  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH] kvm: x86: fix a race condition result to lost INIT

2017-07-30 Thread Peng Hao
when SMP VM start, AP may lost INIT because of receiving INIT between
kvm_vcpu_ioctl_x86_get/set_vcpu_events.

   vcpu 0 vcpu 1
   kvm_vcpu_ioctl_x86_get_vcpu_events
   events->smi.latched_init=0
 send INIT to vcpu1
   set vcpu1's pending_events
   kvm_vcpu_ioctl_x86_set_vcpu_events
events->smi.latched_init == 0
  clear INIT in pending_events
I don't think it need set/clear kernel state according to userspace's
info.

Signed-off-by: Peng Hao 
---
 arch/x86/kvm/x86.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6c7266f..393a7b7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3157,12 +3157,6 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct 
kvm_vcpu *vcpu,
vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
else
vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK;
-   if (lapic_in_kernel(vcpu)) {
-   if (events->smi.latched_init)
-   set_bit(KVM_APIC_INIT, 
&vcpu->arch.apic->pending_events);
-   else
-   clear_bit(KVM_APIC_INIT, 
&vcpu->arch.apic->pending_events);
-   }
}
 
kvm_make_request(KVM_REQ_EVENT, vcpu);
-- 
1.8.3.1




[PATCH 00/29] constify scsi pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Arvind Yadav (29):
  [PATCH 01/29] scsi: qla1280: constify pci_device_id.
  [PATCH 02/29] scsi: qedi: constify pci_device_id.
  [PATCH 03/29] scsi: am53c974: constify pci_device_id.
  [PATCH 04/29] scsi: pm8001: constify pci_device_id.
  [PATCH 05/29] scsi: qla4xxx: constify pci_device_id.
  [PATCH 06/29] scsi: mvsas: constify pci_device_id.
  [PATCH 07/29] scsi: 3w-9xxx: constify pci_device_id.
  [PATCH 08/29] scsi: ipr: constify pci_device_id.
  [PATCH 09/29] scsi: arcmsr: constify pci_device_id.
  [PATCH 10/29] scsi: dpt_i2o: constify pci_device_id.
  [PATCH 11/29] scsi: 3w-sas: constify pci_device_id.
  [PATCH 12/29] scsi: hptiop: constify pci_device_id.
  [PATCH 13/29] scsi: fdomain: constify pci_device_id.
  [PATCH 14/29] scsi: snic: constify pci_device_id.
  [PATCH 15/29] scsi: sym53c8xx_2: constify pci_device_id.
  [PATCH 16/29] scsi: esas2r: constify pci_device_id.
  [PATCH 17/29] scsi: qla2xxx: constify pci_device_id.
  [PATCH 18/29] scsi: dmx3191d: constify pci_device_id.
  [PATCH 19/29] scsi: megaraid: constify pci_device_id.
  [PATCH 20/29] scsi: cxlflash: constify pci_device_id.
  [PATCH 21/29] scsi: nsp32: constify pci_device_id.
  [PATCH 22/29] scsi: pmcraid: constify pci_device_id.
  [PATCH 23/29] scsi: fnic: constify pci_device_id.
  [PATCH 24/29] scsi: stex: constify pci_device_id.
  [PATCH 25/29] scsi: megaraid: constify pci_device_id.
  [PATCH 26/29] scsi: a100u2w: constify pci_device_id.
  [PATCH 27/29] scsi: advansys: constify pci_device_id.
  [PATCH 28/29] scsi: atp870u: constify pci_device_id.
  [PATCH 29/29] scsi: 3w-: constify pci_device_id.

 drivers/scsi/3w-9xxx.c| 2 +-
 drivers/scsi/3w-sas.c | 2 +-
 drivers/scsi/3w-.c| 2 +-
 drivers/scsi/a100u2w.c| 2 +-
 drivers/scsi/advansys.c   | 2 +-
 drivers/scsi/am53c974.c   | 2 +-
 drivers/scsi/arcmsr/arcmsr_hba.c  | 2 +-
 drivers/scsi/atp870u.c| 2 +-
 drivers/scsi/cxlflash/main.c  | 2 +-
 drivers/scsi/dmx3191d.c   | 2 +-
 drivers/scsi/dpt_i2o.c| 2 +-
 drivers/scsi/esas2r/esas2r_main.c | 2 +-
 drivers/scsi/fdomain.c| 2 +-
 drivers/scsi/fnic/fnic_main.c | 2 +-
 drivers/scsi/hptiop.c | 2 +-
 drivers/scsi/ipr.c| 2 +-
 drivers/scsi/megaraid.c   | 2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 drivers/scsi/mvsas/mv_init.c  | 2 +-
 drivers/scsi/nsp32.c  | 2 +-
 drivers/scsi/pm8001/pm8001_init.c | 2 +-
 drivers/scsi/pmcraid.c| 2 +-
 drivers/scsi/qedi/qedi_main.c | 2 +-
 drivers/scsi/qla1280.c| 2 +-
 drivers/scsi/qla2xxx/qla_os.c | 2 +-
 drivers/scsi/qla4xxx/ql4_os.c | 2 +-
 drivers/scsi/snic/snic_main.c | 2 +-
 drivers/scsi/stex.c   | 2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c   | 2 +-
 29 files changed, 29 insertions(+), 29 deletions(-)

-- 
2.7.4



[PATCH 05/29] scsi: qla4xxx: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/qla4xxx/ql4_os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 64c6fa5..41e1027 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -9793,7 +9793,7 @@ static const struct pci_error_handlers 
qla4xxx_err_handler = {
.resume = qla4xxx_pci_resume,
 };
 
-static struct pci_device_id qla4xxx_pci_tbl[] = {
+static const struct pci_device_id qla4xxx_pci_tbl[] = {
{
.vendor = PCI_VENDOR_ID_QLOGIC,
.device = PCI_DEVICE_ID_QLOGIC_ISP4010,
-- 
2.7.4



[PATCH 06/29] scsi: mvsas: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/mvsas/mv_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 4e047b5..552c5a0 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -659,7 +659,7 @@ static void mvs_pci_remove(struct pci_dev *pdev)
return;
 }
 
-static struct pci_device_id mvs_pci_table[] = {
+static const struct pci_device_id mvs_pci_table[] = {
{ PCI_VDEVICE(MARVELL, 0x6320), chip_6320 },
{ PCI_VDEVICE(MARVELL, 0x6340), chip_6440 },
{
-- 
2.7.4



[PATCH 07/29] scsi: 3w-9xxx: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/3w-9xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 00e7968..27fa387 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -2274,7 +2274,7 @@ static int twa_resume(struct pci_dev *pdev)
 #endif
 
 /* PCI Devices supported by this driver */
-static struct pci_device_id twa_pci_tbl[] = {
+static const struct pci_device_id twa_pci_tbl[] = {
{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9000,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
-- 
2.7.4



[PATCH 03/29] scsi: am53c974: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/am53c974.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/am53c974.c b/drivers/scsi/am53c974.c
index beea30e..ffc49d0 100644
--- a/drivers/scsi/am53c974.c
+++ b/drivers/scsi/am53c974.c
@@ -542,7 +542,7 @@ static void pci_esp_remove_one(struct pci_dev *pdev)
scsi_host_put(esp->host);
 }
 
-static struct pci_device_id am53c974_pci_tbl[] = {
+static const struct pci_device_id am53c974_pci_tbl[] = {
{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SCSI,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
{ }
-- 
2.7.4



[PATCH 01/29] scsi: qla1280: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/qla1280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 8a29fb0..265a65b 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -537,7 +537,7 @@ struct qla_boards {
 };
 
 /* NOTE: the last argument in each entry is used to index ql1280_board_tbl */
-static struct pci_device_id qla1280_pci_tbl[] = {
+static const struct pci_device_id qla1280_pci_tbl[] = {
{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP12160,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020,
-- 
2.7.4



[PATCH 10/29] scsi: dpt_i2o: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/dpt_i2o.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 256dd67..ba90cc4 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -181,7 +181,7 @@ static u8 adpt_read_blink_led(adpt_hba* host)
  */
 
 #ifdef MODULE
-static struct pci_device_id dptids[] = {
+static const struct pci_device_id dptids[] = {
{ PCI_DPT_VENDOR_ID, PCI_DPT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
{ PCI_DPT_VENDOR_ID, PCI_DPT_RAPTOR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
{ 0, }
-- 
2.7.4



[PATCH 09/29] scsi: arcmsr: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/arcmsr/arcmsr_hba.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index af032c4..392fb07 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -141,7 +141,7 @@ static struct scsi_host_template arcmsr_scsi_host_template 
= {
.no_write_same  = 1,
 };
 
-static struct pci_device_id arcmsr_device_id_table[] = {
+static const struct pci_device_id arcmsr_device_id_table[] = {
{PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1110),
.driver_data = ACB_ADAPTER_TYPE_A},
{PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1120),
-- 
2.7.4



[PATCH 04/29] scsi: pm8001: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/pm8001/pm8001_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c 
b/drivers/scsi/pm8001/pm8001_init.c
index 034b2f7..f2757cc 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -1270,7 +1270,7 @@ static int pm8001_pci_resume(struct pci_dev *pdev)
 /* update of pci device, vendor id and driver data with
  * unique value for each of the controller
  */
-static struct pci_device_id pm8001_pci_table[] = {
+static const struct pci_device_id pm8001_pci_table[] = {
{ PCI_VDEVICE(PMC_Sierra, 0x8001), chip_8001 },
{ PCI_VDEVICE(PMC_Sierra, 0x8006), chip_8006 },
{ PCI_VDEVICE(ADAPTEC2, 0x8006), chip_8006 },
-- 
2.7.4



[PATCH 08/29] scsi: ipr: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/ipr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index b0c68d2..edc7030 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -10644,7 +10644,7 @@ static void ipr_shutdown(struct pci_dev *pdev)
}
 }
 
-static struct pci_device_id ipr_pci_table[] = {
+static const struct pci_device_id ipr_pci_table[] = {
{ PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE,
PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_5702, 0, 0, 0 },
{ PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE,
-- 
2.7.4



[PATCH 02/29] scsi: qedi: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/qedi/qedi_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index 5f5a4ef..3880bf8 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -2004,7 +2004,7 @@ static void qedi_remove(struct pci_dev *pdev)
__qedi_remove(pdev, QEDI_MODE_NORMAL);
 }
 
-static struct pci_device_id qedi_pci_tbl[] = {
+static const struct pci_device_id qedi_pci_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, 0x165E) },
{ PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, 0x8084) },
{ 0 },
-- 
2.7.4



[PATCH 19/29] scsi: megaraid: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/megaraid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 3c63c29..17012c8 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -4652,7 +4652,7 @@ megaraid_shutdown(struct pci_dev *pdev)
__megaraid_shutdown(adapter);
 }
 
-static struct pci_device_id megaraid_pci_tbl[] = {
+static const struct pci_device_id megaraid_pci_tbl[] = {
{PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID2,
-- 
2.7.4



[PATCH 16/29] scsi: esas2r: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/esas2r/esas2r_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/esas2r/esas2r_main.c 
b/drivers/scsi/esas2r/esas2r_main.c
index f2e9d8a..81f226b 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -309,7 +309,7 @@ MODULE_PARM_DESC(interrupt_mode,
 "Defines the interrupt mode to use.  0 for legacy"
 ", 1 for MSI.  Default is MSI (1).");
 
-static struct pci_device_id
+static const struct pci_device_id
esas2r_pci_table[] = {
{ ATTO_VENDOR_ID, 0x0049, ATTO_VENDOR_ID, 0x0049,
  0,
-- 
2.7.4



[PATCH 15/29] scsi: sym53c8xx_2: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c 
b/drivers/scsi/sym53c8xx_2/sym_glue.c
index d32e3ba..6934265 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2000,7 +2000,7 @@ static struct spi_function_template 
sym2_transport_functions = {
.get_signalling = sym2_get_signalling,
 };
 
-static struct pci_device_id sym2_id_table[] = {
+static const struct pci_device_id sym2_id_table[] = {
{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C810,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C820,
-- 
2.7.4



[PATCH 11/29] scsi: 3w-sas: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/3w-sas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index b150e13..e771e86 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1847,7 +1847,7 @@ static int twl_resume(struct pci_dev *pdev)
 #endif
 
 /* PCI Devices supported by this driver */
-static struct pci_device_id twl_pci_tbl[] = {
+static const struct pci_device_id twl_pci_tbl[] = {
{ PCI_VDEVICE(3WARE, PCI_DEVICE_ID_3WARE_9750) },
{ }
 };
-- 
2.7.4



[PATCH 18/29] scsi: dmx3191d: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/dmx3191d.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c
index 6af3394..805ae59 100644
--- a/drivers/scsi/dmx3191d.c
+++ b/drivers/scsi/dmx3191d.c
@@ -139,7 +139,7 @@ static void dmx3191d_remove_one(struct pci_dev *pdev)
pci_disable_device(pdev);
 }
 
-static struct pci_device_id dmx3191d_pci_tbl[] = {
+static const struct pci_device_id dmx3191d_pci_tbl[] = {
{PCI_VENDOR_ID_DOMEX, PCI_DEVICE_ID_DOMEX_DMX3191D,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
{ }
-- 
2.7.4



[PATCH 14/29] scsi: snic: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/snic/snic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c
index 7cf70aa..74031e4 100644
--- a/drivers/scsi/snic/snic_main.c
+++ b/drivers/scsi/snic/snic_main.c
@@ -35,7 +35,7 @@
 #define PCI_DEVICE_ID_CISCO_SNIC   0x0046
 
 /* Supported devices by snic module */
-static struct pci_device_id snic_id_table[] = {
+static const struct pci_device_id snic_id_table[] = {
{PCI_DEVICE(0x1137, PCI_DEVICE_ID_CISCO_SNIC) },
{ 0, }  /* end of table */
 };
-- 
2.7.4



[PATCH 20/29] scsi: cxlflash: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/cxlflash/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 077f62e..88bd551 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -3155,7 +3155,7 @@ static struct dev_dependent_vals dev_briard_vals = { 
CXLFLASH_MAX_SECTORS,
 /*
  * PCI device binding table
  */
-static struct pci_device_id cxlflash_pci_table[] = {
+static const struct pci_device_id cxlflash_pci_table[] = {
{PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CORSA,
 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&dev_corsa_vals},
{PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_FLASH_GT,
-- 
2.7.4



[PATCH 17/29] scsi: qla2xxx: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/qla2xxx/qla_os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index df57655..2ee8e86 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -6494,7 +6494,7 @@ static const struct pci_error_handlers 
qla2xxx_err_handler = {
.resume = qla2xxx_pci_resume,
 };
 
-static struct pci_device_id qla2xxx_pci_tbl[] = {
+static const struct pci_device_id qla2xxx_pci_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) },
{ PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) },
{ PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) },
-- 
2.7.4



[PATCH 12/29] scsi: hptiop: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/hptiop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 7226226..31415b8 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1647,7 +1647,7 @@ static struct hptiop_adapter_ops hptiop_mvfrey_ops = {
.host_phy_flag = cpu_to_le64(1),
 };
 
-static struct pci_device_id hptiop_id_table[] = {
+static const struct pci_device_id hptiop_id_table[] = {
{ PCI_VDEVICE(TTI, 0x3220), (kernel_ulong_t)&hptiop_itl_ops },
{ PCI_VDEVICE(TTI, 0x3320), (kernel_ulong_t)&hptiop_itl_ops },
{ PCI_VDEVICE(TTI, 0x3410), (kernel_ulong_t)&hptiop_itl_ops },
-- 
2.7.4



[PATCH 13/29] scsi: fdomain: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/fdomain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index b87ab38..d46cbe8 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -1770,7 +1770,7 @@ struct scsi_host_template fdomain_driver_template = {
 #ifndef PCMCIA
 #if defined(CONFIG_PCI) && defined(MODULE)
 
-static struct pci_device_id fdomain_pci_tbl[] = {
+static const struct pci_device_id fdomain_pci_tbl[] = {
{ PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ }
-- 
2.7.4



[PATCH 22/29] scsi: pmcraid: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/pmcraid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 1cc814f..1a9e153 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -126,7 +126,7 @@ static struct pmcraid_chip_details pmcraid_chip_cfg[] = {
 /*
  * PCI device ids supported by pmcraid driver
  */
-static struct pci_device_id pmcraid_pci_table[] = {
+static const struct pci_device_id pmcraid_pci_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_PMC, PCI_DEVICE_ID_PMC_MAXRAID),
  0, 0, (kernel_ulong_t)&pmcraid_chip_cfg[0]
},
-- 
2.7.4



[PATCH 21/29] scsi: nsp32: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/nsp32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 53c8477..1430b3c 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -76,7 +76,7 @@ static const char *nsp32_release_version = "1.2";
 /
  * Supported hardware
  */
-static struct pci_device_id nsp32_pci_table[] = {
+static const struct pci_device_id nsp32_pci_table[] = {
{
.vendor  = PCI_VENDOR_ID_IODATA,
.device  = PCI_DEVICE_ID_NINJASCSI_32BI_CBSC_II,
-- 
2.7.4



[PATCH 26/29] scsi: a100u2w: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/a100u2w.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index 8086bd0..80c39fd 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -1209,7 +1209,7 @@ static void inia100_remove_one(struct pci_dev *pdev)
scsi_host_put(shost);
 } 
 
-static struct pci_device_id inia100_pci_tbl[] = {
+static const struct pci_device_id inia100_pci_tbl[] = {
{PCI_VENDOR_ID_INIT, 0x1060, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0,}
 };
-- 
2.7.4



[PATCH 25/29] scsi: megaraid: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 316c3df..ed2acda 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -124,7 +124,7 @@ static int megasas_get_target_prop(struct megasas_instance 
*instance,
 /*
  * PCI ID table for all supported controllers
  */
-static struct pci_device_id megasas_pci_table[] = {
+static const struct pci_device_id megasas_pci_table[] = {
 
{PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064R)},
/* xscale IOP */
-- 
2.7.4



[PATCH 28/29] scsi: atp870u: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/atp870u.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index 8b52a9d..70f1bc4 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -1685,7 +1685,7 @@ static struct scsi_host_template atp870u_template = {
  .max_sectors  = ATP870U_MAX_SECTORS,
 };
 
-static struct pci_device_id atp870u_id_table[] = {
+static const struct pci_device_id atp870u_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP885_DEVID)   },
{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP880_DEVID1)
  },
{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, ATP880_DEVID2)
  },
-- 
2.7.4



[PATCH 29/29] scsi: 3w-xxxx: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/3w-.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/3w-.c b/drivers/scsi/3w-.c
index 33261b6..e0b079d 100644
--- a/drivers/scsi/3w-.c
+++ b/drivers/scsi/3w-.c
@@ -2384,7 +2384,7 @@ static void tw_remove(struct pci_dev *pdev)
 } /* End tw_remove() */
 
 /* PCI Devices supported by this driver */
-static struct pci_device_id tw_pci_tbl[] = {
+static const struct pci_device_id tw_pci_tbl[] = {
{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_1000,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{ PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_7000,
-- 
2.7.4



[PATCH 24/29] scsi: stex: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/stex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 9b20643..21d0495 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -1491,7 +1491,7 @@ static struct scsi_host_template driver_template = {
.this_id= -1,
 };
 
-static struct pci_device_id stex_pci_tbl[] = {
+static const struct pci_device_id stex_pci_tbl[] = {
/* st_shasta */
{ 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
st_shasta }, /* SuperTrak EX8350/8300/16350/16300 */
-- 
2.7.4



[PATCH 27/29] scsi: advansys: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/advansys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 24e57e7..350070f 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -11714,7 +11714,7 @@ static struct eisa_driver advansys_eisa_driver = {
 };
 
 /* PCI Devices supported by this driver */
-static struct pci_device_id advansys_pci_tbl[] = {
+static const struct pci_device_id advansys_pci_tbl[] = {
{PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
-- 
2.7.4



[PATCH 23/29] scsi: fnic: constify pci_device_id.

2017-07-30 Thread Arvind Yadav
pci_device_id are not supposed to change at runtime. All functions
working with pci_device_id provided by  work with
const pci_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/fnic/fnic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index aacadbf..b3ab344 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -53,7 +53,7 @@ LIST_HEAD(fnic_list);
 DEFINE_SPINLOCK(fnic_list_lock);
 
 /* Supported devices by fnic module */
-static struct pci_device_id fnic_id_table[] = {
+static const struct pci_device_id fnic_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_FNIC) },
{ 0, }
 };
-- 
2.7.4



[GIT pull] irq fix for 4.13

2017-07-30 Thread Thomas Gleixner
Linus,

please pull the latest irq-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
irq-urgent-for-linus


Fix for a regression caused by the conversion of x86 to the generic hotplug
code. Instead of doing a plain single line revert, this adds a pile of
comments so the semantics of the force argument are clear.

Thanks,

tglx

-->
Thomas Gleixner (1):
  genirq/cpuhotplug: Revert "Set force affinity flag on hotplug migration"


 include/linux/irq.h | 7 ++-
 kernel/irq/cpuhotplug.c | 9 +++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 00db35b61e9e..d2d543794093 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -388,7 +388,12 @@ static inline irq_hw_number_t irqd_to_hwirq(struct 
irq_data *d)
  * @irq_mask_ack:  ack and mask an interrupt source
  * @irq_unmask:unmask an interrupt source
  * @irq_eoi:   end of interrupt
- * @irq_set_affinity:  set the CPU affinity on SMP machines
+ * @irq_set_affinity:  Set the CPU affinity on SMP machines. If the force
+ * argument is true, it tells the driver to
+ * unconditionally apply the affinity setting. Sanity
+ * checks against the supplied affinity mask are not
+ * required. This is used for CPU hotplug where the
+ * target CPU is not yet set in the cpu_online_mask.
  * @irq_retrigger: resend an IRQ to the CPU
  * @irq_set_type:  set the flow type (IRQ_TYPE_LEVEL/etc.) of an IRQ
  * @irq_set_wake:  enable/disable power-management wake-on of an IRQ
diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
index aee8f7ec40af..638eb9c83d9f 100644
--- a/kernel/irq/cpuhotplug.c
+++ b/kernel/irq/cpuhotplug.c
@@ -95,8 +95,13 @@ static bool migrate_one_irq(struct irq_desc *desc)
affinity = cpu_online_mask;
brokeaff = true;
}
-
-   err = irq_do_set_affinity(d, affinity, true);
+   /*
+* Do not set the force argument of irq_do_set_affinity() as this
+* disables the masking of offline CPUs from the supplied affinity
+* mask and therefore might keep/reassign the irq to the outgoing
+* CPU.
+*/
+   err = irq_do_set_affinity(d, affinity, false);
if (err) {
pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n",
d->irq, err);


[GIT pull] perf fixes for 4.13

2017-07-30 Thread Thomas Gleixner
Linus,

please pull the latest perf-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
perf-urgent-for-linus

A couple of fixes for performance counters and kprobes:

  - A series of small patches which make the uncore performance counters on
Skylake server systems work correctly

  - Add a missing instruction slot release to the failure path of kprobes.

Thanks,

tglx

-->
Kan Liang (3):
  perf/x86/intel/uncore: Fix Skylake server PCU PMU event format
  perf/x86/intel/uncore: Fix Skylake server CHA LLC_LOOKUP event umask
  perf/x86/intel/uncore: Remove invalid Skylake server CHA filter field

Masami Hiramatsu (1):
  kprobes/x86: Release insn_slot in failure path

Stephane Eranian (3):
  perf/x86/intel/uncore: Fix Skylake UPI PMU event masks
  perf/x86/intel/uncore: Fix SKX CHA event extra regs
  perf/x86/intel/uncore: Fix missing marker for skx_uncore_cha_extra_regs


 arch/x86/events/intel/uncore_snbep.c | 51 +---
 arch/x86/kernel/kprobes/core.c   | 10 ++-
 2 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c 
b/arch/x86/events/intel/uncore_snbep.c
index dae2fedc1601..4f9127644b80 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -316,7 +316,7 @@
 #define SKX_UPI_PCI_PMON_CTL0  0x350
 #define SKX_UPI_PCI_PMON_CTR0  0x318
 #define SKX_UPI_PCI_PMON_BOX_CTL   0x378
-#define SKX_PMON_CTL_UMASK_EXT 0xff
+#define SKX_UPI_CTL_UMASK_EXT  0xffefff
 
 /* SKX M2M */
 #define SKX_M2M_PCI_PMON_CTL0  0x228
@@ -328,7 +328,7 @@ DEFINE_UNCORE_FORMAT_ATTR(event2, event, "config:0-6");
 DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");
 DEFINE_UNCORE_FORMAT_ATTR(use_occ_ctr, use_occ_ctr, "config:7");
 DEFINE_UNCORE_FORMAT_ATTR(umask, umask, "config:8-15");
-DEFINE_UNCORE_FORMAT_ATTR(umask_ext, umask, "config:8-15,32-39");
+DEFINE_UNCORE_FORMAT_ATTR(umask_ext, umask, "config:8-15,32-43,45-55");
 DEFINE_UNCORE_FORMAT_ATTR(qor, qor, "config:16");
 DEFINE_UNCORE_FORMAT_ATTR(edge, edge, "config:18");
 DEFINE_UNCORE_FORMAT_ATTR(tid_en, tid_en, "config:19");
@@ -351,7 +351,6 @@ DEFINE_UNCORE_FORMAT_ATTR(filter_cid, filter_cid, 
"config1:5");
 DEFINE_UNCORE_FORMAT_ATTR(filter_link, filter_link, "config1:5-8");
 DEFINE_UNCORE_FORMAT_ATTR(filter_link2, filter_link, "config1:6-8");
 DEFINE_UNCORE_FORMAT_ATTR(filter_link3, filter_link, "config1:12");
-DEFINE_UNCORE_FORMAT_ATTR(filter_link4, filter_link, "config1:9-12");
 DEFINE_UNCORE_FORMAT_ATTR(filter_nid, filter_nid, "config1:10-17");
 DEFINE_UNCORE_FORMAT_ATTR(filter_nid2, filter_nid, "config1:32-47");
 DEFINE_UNCORE_FORMAT_ATTR(filter_state, filter_state, "config1:18-22");
@@ -3302,7 +3301,6 @@ static struct attribute *skx_uncore_cha_formats_attr[] = {
&format_attr_inv.attr,
&format_attr_thresh8.attr,
&format_attr_filter_tid4.attr,
-   &format_attr_filter_link4.attr,
&format_attr_filter_state5.attr,
&format_attr_filter_rem.attr,
&format_attr_filter_loc.attr,
@@ -3312,7 +3310,6 @@ static struct attribute *skx_uncore_cha_formats_attr[] = {
&format_attr_filter_opc_0.attr,
&format_attr_filter_opc_1.attr,
&format_attr_filter_nc.attr,
-   &format_attr_filter_c6.attr,
&format_attr_filter_isoc.attr,
NULL,
 };
@@ -,8 +3330,11 @@ static struct extra_reg skx_uncore_cha_extra_regs[] = {
SNBEP_CBO_EVENT_EXTRA_REG(0x0534, 0x, 0x4),
SNBEP_CBO_EVENT_EXTRA_REG(0x0934, 0x, 0x4),
SNBEP_CBO_EVENT_EXTRA_REG(0x1134, 0x, 0x4),
-   SNBEP_CBO_EVENT_EXTRA_REG(0x2134, 0x, 0x4),
-   SNBEP_CBO_EVENT_EXTRA_REG(0x8134, 0x, 0x4),
+   SNBEP_CBO_EVENT_EXTRA_REG(0x3134, 0x, 0x4),
+   SNBEP_CBO_EVENT_EXTRA_REG(0x9134, 0x, 0x4),
+   SNBEP_CBO_EVENT_EXTRA_REG(0x35, 0xff, 0x8),
+   SNBEP_CBO_EVENT_EXTRA_REG(0x36, 0xff, 0x8),
+   EVENT_EXTRA_END
 };
 
 static u64 skx_cha_filter_mask(int fields)
@@ -3347,6 +3347,17 @@ static u64 skx_cha_filter_mask(int fields)
mask |= SKX_CHA_MSR_PMON_BOX_FILTER_LINK;
if (fields & 0x4)
mask |= SKX_CHA_MSR_PMON_BOX_FILTER_STATE;
+   if (fields & 0x8) {
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_REM;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_LOC;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_ALL_OPC;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_NM;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_NOT_NM;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_OPC0;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_OPC1;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_NC;
+   mask |= SKX_CHA_MSR_PMON_BOX_FILTER_ISOC;
+   }
return mask;
 }
 
@@ -3492,6 +3503,26 @@ static struct intel_uncore_type skx_uncore_irp = {
.fo

[GIT pull] scheduler fixes for 4.13

2017-07-30 Thread Thomas Gleixner
Linus,

please pull the latest sched-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
sched-urgent-for-linus

Two patches addressing build warnings caused by inconsistent kernel doc
comments.

Thanks,

tglx

-->
Jonathan Corbet (2):
  sched/core: Fix some documentation build warnings
  sched/wait: Clean up some documentation warnings


 include/linux/wait.h | 8 
 kernel/sched/core.c  | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index b289c96151ee..5b74e36c0ca8 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -529,13 +529,13 @@ do {  
\
 
 /**
  * wait_event_interruptible_hrtimeout - sleep until a condition gets true or a 
timeout elapses
- * @wq_head: the waitqueue to wait on
+ * @wq: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  * @timeout: timeout, as a ktime_t
  *
  * The process is put to sleep (TASK_INTERRUPTIBLE) until the
  * @condition evaluates to true or a signal is received.
- * The @condition is checked each time the waitqueue @wq_head is woken up.
+ * The @condition is checked each time the waitqueue @wq is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
@@ -735,12 +735,12 @@ extern int do_wait_intr_irq(wait_queue_head_t *, 
wait_queue_entry_t *);
 
 /**
  * wait_event_killable - sleep until a condition gets true
- * @wq: the waitqueue to wait on
+ * @wq_head: the waitqueue to wait on
  * @condition: a C expression for the event to wait for
  *
  * The process is put to sleep (TASK_KILLABLE) until the
  * @condition evaluates to true or a signal is received.
- * The @condition is checked each time the waitqueue @wq is woken up.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 17c667b427b4..0869b20fba81 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2069,7 +2069,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, 
int wake_flags)
 /**
  * try_to_wake_up_local - try to wake up a local task with rq lock held
  * @p: the thread to be awakened
- * @cookie: context's cookie for pinning
+ * @rf: request-queue flags for pinning
  *
  * Put @p on the run-queue if it's not already there. The caller must
  * ensure that this_rq() is locked, @p is bound to this_rq() and not


MEI-related WARN_ON() triggered during resume-from-sleep on v4.12-rc2+

2017-07-30 Thread Dominik Brodowski
Thomas,

on Linus' most recent kernel (v4.12-rc2, git head 0a07b238e5f48), I see the
following message on my Dell XPS13 when resuming from sleep. MEI is, AFAIK,
not being used on this system:

[  192.940537] Restarting tasks ... 
[  192.940610] PGI is not set
[  192.940619] [ cut here ]
[  192.940623] WARNING: CPU: 0 PID: 1661 at 
/home/brodo/local/kernel/git/linux/drivers/misc/mei/hw-me.c:653 
mei_me_pg_exit_sync+0x351/0x360
[  192.940624] Modules linked in:
[  192.940627] CPU: 0 PID: 1661 Comm: kworker/0:3 Not tainted 4.13.0-rc2+ #2
[  192.940628] Hardware name: Dell Inc. XPS 13 9343/0TM99H, BIOS A11 12/08/2016
[  192.940630] Workqueue: pm pm_runtime_work

[  192.940642] Call Trace:
[  192.940646]  ? pci_pme_active+0x1de/0x1f0
[  192.940649]  ? pci_restore_standard_config+0x50/0x50
[  192.940651]  ? kfree+0x172/0x190
[  192.940653]  ? kfree+0x172/0x190
[  192.940655]  ? pci_restore_standard_config+0x50/0x50
[  192.940663]  mei_me_pm_runtime_resume+0x3f/0xc0
[  192.940665]  pci_pm_runtime_resume+0x7a/0xa0
[  192.940667]  __rpm_callback+0xb9/0x1e0
[  192.940668]  ? preempt_count_add+0x6d/0xc0
[  192.940670]  rpm_callback+0x24/0x90
[  192.940672]  ? pci_restore_standard_config+0x50/0x50
[  192.940674]  rpm_resume+0x4e8/0x800
[  192.940676]  pm_runtime_work+0x55/0xb0
[  192.940678]  process_one_work+0x184/0x3e0
[  192.940680]  worker_thread+0x4d/0x3a0
[  192.940681]  ? preempt_count_sub+0x9b/0x100
[  192.940683]  kthread+0x122/0x140
[  192.940684]  ? process_one_work+0x3e0/0x3e0
[  192.940685]  ? __kthread_create_on_node+0x1a0/0x1a0
[  192.940688]  ret_from_fork+0x27/0x40
[  192.940690] Code: 96 3a 9e ff 48 8b 7d 98 e8 cd 21 58 00 83 bb bc 01 00 00 
04 0f 85 40 fe ff ff e9 41 fe ff ff 48 c7 c7 5f 04 99 96 e8 93 6b 9f ff <0f> ff 
e9 5d fd ff ff e8 33 fe 99 ff 0f 1f 00 0f 1f 44 00 00 55 
[  192.940719] ---[ end trace a86955597774ead8 ]---
[  192.942540] done.

This doesn't / didn't happen on v4.12.

Best,
Dominik


signature.asc
Description: PGP signature


[GIT pull] x86 fixes for 4.13

2017-07-30 Thread Thomas Gleixner
Linus,

please pull the latest x86-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
x86-urgent-for-linus

A small set of x86 fixes:

  - Prevent the kernel from using the EFI reboot method when EFI is
disabled.

  - Two patches addressing clang issues
  

Thanks,

tglx

-->
Matthias Kaehlcke (1):
  x86/boot: Disable the address-of-packed-member compiler warning

Michael Davidson (1):
  x86/boot: #undef memcpy() et al in string.c

Stefan Assmann (1):
  x86/efi: Fix reboot_mode when EFI runtime services are disabled


 arch/x86/boot/compressed/Makefile | 1 +
 arch/x86/boot/string.c| 9 +
 arch/x86/kernel/reboot.c  | 6 +++---
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/Makefile 
b/arch/x86/boot/compressed/Makefile
index 2c860ad4fe06..8a958274b54c 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -34,6 +34,7 @@ KBUILD_CFLAGS += $(cflags-y)
 KBUILD_CFLAGS += -mno-mmx -mno-sse
 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 
 KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
 GCOV_PROFILE := n
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 630e3664906b..16f49123d747 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -16,6 +16,15 @@
 #include "ctype.h"
 #include "string.h"
 
+/*
+ * Undef these macros so that the functions that we provide
+ * here will have the correct names regardless of how string.h
+ * may have chosen to #define them.
+ */
+#undef memcpy
+#undef memset
+#undef memcmp
+
 int memcmp(const void *s1, const void *s2, size_t len)
 {
bool diff;
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 67393fc88353..a56bf6051f4e 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -471,12 +471,12 @@ static int __init reboot_init(void)
 
/*
 * The DMI quirks table takes precedence. If no quirks entry
-* matches and the ACPI Hardware Reduced bit is set, force EFI
-* reboot.
+* matches and the ACPI Hardware Reduced bit is set and EFI
+* runtime services are enabled, force EFI reboot.
 */
rv = dmi_check_system(reboot_dmi_table);
 
-   if (!rv && efi_reboot_required())
+   if (!rv && efi_reboot_required() && !efi_runtime_disabled())
reboot_type = BOOT_EFI;
 
return 0;


RE: MEI-related WARN_ON() triggered during resume-from-sleep on v4.12-rc2+

2017-07-30 Thread Winkler, Tomas


> -Original Message-
> From: Dominik Brodowski [mailto:li...@dominikbrodowski.net]
> Sent: Sunday, July 30, 2017 11:59
> To: Winkler, Tomas 
> Cc: Usyskin, Alexander ; linux-
> ker...@vger.kernel.org
> Subject: MEI-related WARN_ON() triggered during resume-from-sleep on
> v4.12-rc2+
> 
> Thomas,
> 
> on Linus' most recent kernel (v4.12-rc2, git head 0a07b238e5f48), I see the
> following message on my Dell XPS13 when resuming from sleep. MEI is,
> AFAIK, not being used on this system:
>

Thanks for the report,  we haven't change the logic of this code since 4.12 so 
we need to look for 
changes  in pci and/or pm subsystems.  We try to bisect it. 

Thanks


 
> [  192.940537] Restarting tasks ...
> [  192.940610] PGI is not set
> [  192.940619] [ cut here ] [  192.940623] WARNING: 
> CPU: 0
> PID: 1661 at /home/brodo/local/kernel/git/linux/drivers/misc/mei/hw-
> me.c:653 mei_me_pg_exit_sync+0x351/0x360 [  192.940624] Modules linked
> in:
> [  192.940627] CPU: 0 PID: 1661 Comm: kworker/0:3 Not tainted 4.13.0-rc2+
> #2 [  192.940628] Hardware name: Dell Inc. XPS 13 9343/0TM99H, BIOS A11
> 12/08/2016 [  192.940630] Workqueue: pm pm_runtime_work  [
> 192.940642] Call Trace:
> [  192.940646]  ? pci_pme_active+0x1de/0x1f0 [  192.940649]  ?
> pci_restore_standard_config+0x50/0x50
> [  192.940651]  ? kfree+0x172/0x190
> [  192.940653]  ? kfree+0x172/0x190
> [  192.940655]  ? pci_restore_standard_config+0x50/0x50
> [  192.940663]  mei_me_pm_runtime_resume+0x3f/0xc0
> [  192.940665]  pci_pm_runtime_resume+0x7a/0xa0 [  192.940667]
> __rpm_callback+0xb9/0x1e0 [  192.940668]  ?
> preempt_count_add+0x6d/0xc0 [  192.940670]  rpm_callback+0x24/0x90 [
> 192.940672]  ? pci_restore_standard_config+0x50/0x50
> [  192.940674]  rpm_resume+0x4e8/0x800
> [  192.940676]  pm_runtime_work+0x55/0xb0 [  192.940678]
> process_one_work+0x184/0x3e0 [  192.940680]  worker_thread+0x4d/0x3a0 [
> 192.940681]  ? preempt_count_sub+0x9b/0x100 [  192.940683]
> kthread+0x122/0x140 [  192.940684]  ? process_one_work+0x3e0/0x3e0 [
> 192.940685]  ? __kthread_create_on_node+0x1a0/0x1a0
> [  192.940688]  ret_from_fork+0x27/0x40
> [  192.940690] Code: 96 3a 9e ff 48 8b 7d 98 e8 cd 21 58 00 83 bb bc 01 00 00
> 04 0f 85 40 fe ff ff e9 41 fe ff ff 48 c7 c7 5f 04 99 96 e8 93 6b 9f ff <0f> 
> ff e9 5d
> fd ff ff e8 33 fe 99 ff 0f 1f 00 0f 1f 44 00 00 55 [  192.940719] ---[ end 
> trace
> a86955597774ead8 ]--- [  192.942540] done.
> 
> This doesn't / didn't happen on v4.12.
> 
> Best,
>   Dominik


Re: [GIT PULL 00/15] perf/core improvements and fixes

2017-07-30 Thread Ingo Molnar

* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> Test results at the end of this message, as usual.
> 
> The following changes since commit ee438ec8f33c5af0d4a4ffb935c5b9272e8c2680:
> 
>   Merge tag 'perf-core-for-mingo-4.14-20170725' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
> (2017-07-26 19:07:30 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
> tags/perf-core-for-mingo-4.14-20170728
> 
> for you to fetch changes up to 6b7007af728df7258bb60ed73099be3b59b3030e:
> 
>   perf data: Add doc when no conversion support compiled (2017-07-28 16:30:45 
> -0300)
> 
> 
> perf/core improvements and fixes for 4.14:
> 
> New features:
> 
> - Add PERF_SAMPLE_CALLCHAIN and PERF_RECORD_MMAP[2] to 'perf data' CTF
>   conversion, allowing CTF trace visualization tools to show callchains
>   and to resolve symbols (Geneviève Bastien)
> 
> Improvements:
> 
> - Use group read for event groups in 'perf stat', reducing overhead when
>   groups are defined in the event specification, i.e. when using {} to
>   enclose a list of events, asking them to be read at the same time,
>   e.g.: "perf stat -e '{cycles,instructions}'" (Jiri Olsa)
> 
> Fixes:
> 
> - Do not overwrite perf_sample->weight in 'perf annotate' when
>   processing samples, use whatever came from the kernel when
>   perf_event_attr.sample_type has PERF_SAMPLE_WEIGHT set or just handle
>   its default value, 0, when that is not set and "weight" is one of the
>   sort orders chosen (Arnaldo Carvalho de Melo)
> 
> - 'perf annotate --show-total-period' fixes:
>- TUI should show period, not nr_samples
>- Set appropriate column width for period/percent
>- Fix the column header to show "Period" when when that is what
>  is being asked for
>   (Taeung Song, Arnaldo Carvalho de Melo)
> 
> - Use default sort if evlist is empty, fixing pipe mode (David 
> Carrillo-Cisneros)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Arnaldo Carvalho de Melo (6):
>   perf annotate: Do not overwrite perf_sample->weight
>   perf annotate stdio: Set enough columns for --show-total-period
>   perf annotate: Fix storing per line sym_hist_entry
>   perf annotate TUI: Use sym_hist_entry in disasm_line_samples
>   perf annotate TUI: Clarify calculation of column header widths
>   perf annotate TUI: Set appropriate column width for period/percent
> 
> David Carrillo-Cisneros (1):
>   perf sort: Use default sort if evlist is empty
> 
> Geneviève Bastien (3):
>   perf data: Add callchain to CTF conversion
>   perf data: Add mmap[2] events to CTF conversion
>   perf data: Add doc when no conversion support compiled
> 
> Jiri Olsa (3):
>   perf tools: Add perf_evsel__read_size function
>   perf evsel: Add read_counter()
>   perf stat: Use group read for event groups
> 
> Taeung Song (2):
>   perf annotate TUI: Fix --show-total-period
>   perf annotate TUI: Fix column header when toggling period/percent
> 
>  tools/perf/builtin-annotate.c |   2 -
>  tools/perf/builtin-data.c |   2 +-
>  tools/perf/builtin-stat.c |  30 +++-
>  tools/perf/ui/browsers/annotate.c |  36 +-
>  tools/perf/util/annotate.c|  11 +--
>  tools/perf/util/counts.h  |   1 +
>  tools/perf/util/data-convert-bt.c | 127 +-
>  tools/perf/util/evlist.h  |   5 ++
>  tools/perf/util/evsel.c   | 139 
> +-
>  tools/perf/util/evsel.h   |   2 +
>  tools/perf/util/sort.c|   2 +-
>  tools/perf/util/stat.c|   4 ++
>  tools/perf/util/stat.h|   5 +-
>  13 files changed, 334 insertions(+), 32 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo


[PATCH] perf build: Clarify header version warning message

2017-07-30 Thread Ingo Molnar
Change this:

  Warning: arch/x86/include/asm/disabled-features.h differs from kernel
  Warning: arch/x86/include/asm/cpufeatures.h differs from kernel
  Warning: arch/powerpc/include/uapi/asm/kvm.h differs from kernel
  Warning: arch/s390/include/uapi/asm/kvm.h differs from kernel

to:

  Warning: Kernel ABI header at 
'tools/arch/x86/include/asm/disabled-features.h' differs from latest version at 
'arch/x86/include/asm/disabled-features.h'
  Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' 
differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
  Warning: Kernel ABI header at 'tools/arch/powerpc/include/uapi/asm/kvm.h' 
differs from latest version at 'arch/powerpc/include/uapi/asm/kvm.h'
  Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/kvm.h' 
differs from latest version at 'arch/s390/include/uapi/asm/kvm.h'

... to make it clearer what the warning is about, and to make it easier to diff 
the two versions when syncing up the files.

Signed-off-by: Ingo Molnar 
---
 tools/perf/check-headers.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 9b6295809a3b..d87bc6af0ac2 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -47,7 +47,7 @@ check () {
   cmd="diff $opts ../$file ../../$file > /dev/null"
 
   test -f ../../$file &&
-  eval $cmd || echo "Warning: $file differs from kernel" >&2
+  eval $cmd || echo "Warning: Kernel ABI header at 'tools/$file' differs from 
latest version at '$file'" >&2
 }
 
 


[tip:perf/core] perf tools: Add perf_evsel__read_size function

2017-07-30 Thread tip-bot for Jiri Olsa
Commit-ID:  de63403bfd14ae8d613f30c9a0d415581b4cb37e
Gitweb: http://git.kernel.org/tip/de63403bfd14ae8d613f30c9a0d415581b4cb37e
Author: Jiri Olsa 
AuthorDate: Wed, 26 Jul 2017 14:02:04 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 26 Jul 2017 14:20:28 -0300

perf tools: Add perf_evsel__read_size function

Currently we use the size of struct perf_counts_values to read the
event, which prevents us to put any new member to the struct.

Adding perf_evsel__read_size to return size of the buffer needed for
event read.

Signed-off-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170726120206.9099-2-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evsel.c | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 450b5fa..4dd0fcc 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1261,15 +1261,42 @@ void perf_counts_values__scale(struct 
perf_counts_values *count,
*pscaled = scaled;
 }
 
+static int perf_evsel__read_size(struct perf_evsel *evsel)
+{
+   u64 read_format = evsel->attr.read_format;
+   int entry = sizeof(u64); /* value */
+   int size = 0;
+   int nr = 1;
+
+   if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
+   size += sizeof(u64);
+
+   if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
+   size += sizeof(u64);
+
+   if (read_format & PERF_FORMAT_ID)
+   entry += sizeof(u64);
+
+   if (read_format & PERF_FORMAT_GROUP) {
+   nr = evsel->nr_members;
+   size += sizeof(u64);
+   }
+
+   size += entry * nr;
+   return size;
+}
+
 int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
 struct perf_counts_values *count)
 {
+   size_t size = perf_evsel__read_size(evsel);
+
memset(count, 0, sizeof(*count));
 
if (FD(evsel, cpu, thread) < 0)
return -EINVAL;
 
-   if (readn(FD(evsel, cpu, thread), count, sizeof(*count)) <= 0)
+   if (readn(FD(evsel, cpu, thread), count->values, size) <= 0)
return -errno;
 
return 0;


[tip:perf/core] perf evsel: Add read_counter()

2017-07-30 Thread tip-bot for Jiri Olsa
Commit-ID:  f7794d525447f1e4e4b2228dd29dba084005e6bf
Gitweb: http://git.kernel.org/tip/f7794d525447f1e4e4b2228dd29dba084005e6bf
Author: Jiri Olsa 
AuthorDate: Wed, 26 Jul 2017 14:02:05 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 26 Jul 2017 14:21:59 -0300

perf evsel: Add read_counter()

Add perf_evsel__read_counter() to read single or group counter. After
calling this function the counter's evsel::counts struct is filled with
values for the counter and member of its group if there are any.

Signed-off-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170726120206.9099-3-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evsel.c | 100 
 tools/perf/util/evsel.h |   2 +
 tools/perf/util/stat.c  |   4 ++
 tools/perf/util/stat.h  |   5 ++-
 4 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 4dd0fcc..89aecf3 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1302,6 +1302,106 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, 
int thread,
return 0;
 }
 
+static int
+perf_evsel__read_one(struct perf_evsel *evsel, int cpu, int thread)
+{
+   struct perf_counts_values *count = perf_counts(evsel->counts, cpu, 
thread);
+
+   return perf_evsel__read(evsel, cpu, thread, count);
+}
+
+static void
+perf_evsel__set_count(struct perf_evsel *counter, int cpu, int thread,
+ u64 val, u64 ena, u64 run)
+{
+   struct perf_counts_values *count;
+
+   count = perf_counts(counter->counts, cpu, thread);
+
+   count->val= val;
+   count->ena= ena;
+   count->run= run;
+}
+
+static int
+perf_evsel__process_group_data(struct perf_evsel *leader,
+  int cpu, int thread, u64 *data)
+{
+   u64 read_format = leader->attr.read_format;
+   struct sample_read_value *v;
+   u64 nr, ena = 0, run = 0, i;
+
+   nr = *data++;
+
+   if (nr != (u64) leader->nr_members)
+   return -EINVAL;
+
+   if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
+   ena = *data++;
+
+   if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
+   run = *data++;
+
+   v = (struct sample_read_value *) data;
+
+   perf_evsel__set_count(leader, cpu, thread,
+ v[0].value, ena, run);
+
+   for (i = 1; i < nr; i++) {
+   struct perf_evsel *counter;
+
+   counter = perf_evlist__id2evsel(leader->evlist, v[i].id);
+   if (!counter)
+   return -EINVAL;
+
+   perf_evsel__set_count(counter, cpu, thread,
+ v[i].value, ena, run);
+   }
+
+   return 0;
+}
+
+static int
+perf_evsel__read_group(struct perf_evsel *leader, int cpu, int thread)
+{
+   struct perf_stat_evsel *ps = leader->priv;
+   u64 read_format = leader->attr.read_format;
+   int size = perf_evsel__read_size(leader);
+   u64 *data = ps->group_data;
+
+   if (!(read_format & PERF_FORMAT_ID))
+   return -EINVAL;
+
+   if (!perf_evsel__is_group_leader(leader))
+   return -EINVAL;
+
+   if (!data) {
+   data = zalloc(size);
+   if (!data)
+   return -ENOMEM;
+
+   ps->group_data = data;
+   }
+
+   if (FD(leader, cpu, thread) < 0)
+   return -EINVAL;
+
+   if (readn(FD(leader, cpu, thread), data, size) <= 0)
+   return -errno;
+
+   return perf_evsel__process_group_data(leader, cpu, thread, data);
+}
+
+int perf_evsel__read_counter(struct perf_evsel *evsel, int cpu, int thread)
+{
+   u64 read_format = evsel->attr.read_format;
+
+   if (read_format & PERF_FORMAT_GROUP)
+   return perf_evsel__read_group(evsel, cpu, thread);
+   else
+   return perf_evsel__read_one(evsel, cpu, thread);
+}
+
 int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
  int cpu, int thread, bool scale)
 {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index fb40ca3..de03c18 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -299,6 +299,8 @@ static inline bool perf_evsel__match2(struct perf_evsel *e1,
 int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
 struct perf_counts_values *count);
 
+int perf_evsel__read_counter(struct perf_evsel *evsel, int cpu, int thread);
+
 int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
  int cpu, int thread, bool scale);
 
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 53b9a99..35e9848 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -128,6 +128,10 @@ static int perf_evsel__alloc

[tip:perf/core] perf stat: Use group read for event groups

2017-07-30 Thread tip-bot for Jiri Olsa
Commit-ID:  82bf311e15d22e2fa45423b1fb4a21cf925381fe
Gitweb: http://git.kernel.org/tip/82bf311e15d22e2fa45423b1fb4a21cf925381fe
Author: Jiri Olsa 
AuthorDate: Wed, 26 Jul 2017 14:02:06 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 26 Jul 2017 14:25:44 -0300

perf stat: Use group read for event groups

Make perf stat use  group read if there  are groups defined. The group
read will get the values for all member of groups within a single
syscall instead of calling read syscall for every event.

We can see considerable less amount of kernel cycles spent on single
group read, than reading each event separately, like for following perf
stat command:

  # perf stat -e {cycles,instructions} -I 10 -a sleep 1

Monitored with "perf stat -r 5 -e '{cycles:u,cycles:k}'"

Before:

24,325,676  cycles:u
   297,040,775  cycles:k

   1.038554134 seconds time elapsed

After:
25,034,418  cycles:u
   158,256,395  cycles:k

   1.036864497 seconds time elapsed

The perf_evsel__open fallback changes contributed by Andi Kleen.

Signed-off-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170726120206.9099-4-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 30 +++---
 tools/perf/util/counts.h  |  1 +
 tools/perf/util/evsel.c   | 10 ++
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 48ac53b..866da7a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -213,10 +213,20 @@ static void perf_stat__reset_stats(void)
 static int create_perf_stat_counter(struct perf_evsel *evsel)
 {
struct perf_event_attr *attr = &evsel->attr;
+   struct perf_evsel *leader = evsel->leader;
 
-   if (stat_config.scale)
+   if (stat_config.scale) {
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
PERF_FORMAT_TOTAL_TIME_RUNNING;
+   }
+
+   /*
+* The event is part of non trivial group, let's enable
+* the group read (for leader) and ID retrieval for all
+* members.
+*/
+   if (leader->nr_members > 1)
+   attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP;
 
attr->inherit = !no_inherit;
 
@@ -333,13 +343,21 @@ static int read_counter(struct perf_evsel *counter)
struct perf_counts_values *count;
 
count = perf_counts(counter->counts, cpu, thread);
-   if (perf_evsel__read(counter, cpu, thread, count)) {
+
+   /*
+* The leader's group read loads data into its group 
members
+* (via perf_evsel__read_counter) and sets threir 
count->loaded.
+*/
+   if (!count->loaded &&
+   perf_evsel__read_counter(counter, cpu, thread)) {
counter->counts->scaled = -1;
perf_counts(counter->counts, cpu, thread)->ena 
= 0;
perf_counts(counter->counts, cpu, thread)->run 
= 0;
return -1;
}
 
+   count->loaded = false;
+
if (STAT_RECORD) {
if (perf_evsel__write_stat_event(counter, cpu, 
thread, count)) {
pr_err("failed to write stat event\n");
@@ -559,6 +577,11 @@ static int store_counter_ids(struct perf_evsel *counter)
return __store_counter_ids(counter, cpus, threads);
 }
 
+static bool perf_evsel__should_store_id(struct perf_evsel *counter)
+{
+   return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID;
+}
+
 static int __run_perf_stat(int argc, const char **argv)
 {
int interval = stat_config.interval;
@@ -631,7 +654,8 @@ try_again:
if (l > unit_width)
unit_width = l;
 
-   if (STAT_RECORD && store_counter_ids(counter))
+   if (perf_evsel__should_store_id(counter) &&
+   store_counter_ids(counter))
return -1;
}
 
diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h
index 34d8baa..cb45a6a 100644
--- a/tools/perf/util/counts.h
+++ b/tools/perf/util/counts.h
@@ -12,6 +12,7 @@ struct perf_counts_values {
};
u64 values[3];
};
+   boolloaded;
 };
 
 struct perf_counts {
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 89aecf3..3735c9e 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -49,6 +49,7 @@ static struct {
bool clockid_wrong;
bool lbr_flags;
bool write_backward;
+   bool group_read;
 }

[tip:perf/core] perf annotate stdio: Set enough columns for --show-total-period

2017-07-30 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  ce9ee4a2de20062a97ad50ecc11ebda7e7618fd1
Gitweb: http://git.kernel.org/tip/ce9ee4a2de20062a97ad50ecc11ebda7e7618fd1
Author: Arnaldo Carvalho de Melo 
AuthorDate: Wed, 26 Jul 2017 17:16:46 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 26 Jul 2017 17:16:46 -0300

perf annotate stdio: Set enough columns for --show-total-period

Now that we set the first column header according to wether
--show-total-period is being used, we need to size it accordingly.

Based-on-a-patch-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/n/tip-pu504ffnit4m334k09hxc...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c2b4b00..5125c2b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1142,7 +1142,7 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
color = get_percent_color(percent);
 
if (symbol_conf.show_total_period)
-   color_fprintf(stdout, color, " %7" PRIu64,
+   color_fprintf(stdout, color, " %11" PRIu64,
  sample.period);
else
color_fprintf(stdout, color, " %7.2f", percent);
@@ -1165,7 +1165,7 @@ static int disasm_line__print(struct disasm_line *dl, 
struct symbol *sym, u64 st
} else if (max_lines && printed >= max_lines)
return 1;
else {
-   int width = 8;
+   int width = symbol_conf.show_total_period ? 12 : 8;
 
if (queue)
return -1;
@@ -1806,7 +1806,7 @@ int symbol__annotate_printf(struct symbol *sym, struct 
map *map,
int printed = 2, queue_len = 0;
int more = 0;
u64 len;
-   int width = 8;
+   int width = symbol_conf.show_total_period ? 12 : 8;
int graph_dotted_len;
 
filename = strdup(dso->long_name);


[tip:perf/core] perf annotate: Do not overwrite perf_sample->weight

2017-07-30 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  c6c13be76c1fc8a3169dbd29cd1d42af1d64773f
Gitweb: http://git.kernel.org/tip/c6c13be76c1fc8a3169dbd29cd1d42af1d64773f
Author: Arnaldo Carvalho de Melo 
AuthorDate: Wed, 26 Jul 2017 16:52:25 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 26 Jul 2017 16:52:25 -0300

perf annotate: Do not overwrite perf_sample->weight

When we parse an event we may get a value from the kernel in response to
PERF_SAMPLE_WEIGHT being set in perf_event_attr->sample_type, and if it
is not set, then perf_sample->weight will be set to zero, which should
be ok according to a discussion with Andi Kleen [1]:

1: https://lkml.kernel.org/r/20170724174637.gs3...@two.firstfloor.org

Acked-by: Andi Kleen 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Cc: Taeung Song 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-8ev8ufk3lzmvgz37yg9nv...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-annotate.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 6db782d..658c920 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -177,8 +177,6 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
 */
process_branch_stack(sample->branch_stack, al, sample);
 
-   sample->weight = 1;
-
he = hists__add_entry(hists, al, NULL, NULL, NULL, sample, true);
if (he == NULL)
return -ENOMEM;


[tip:perf/core] perf annotate: Fix storing per line sym_hist_entry

2017-07-30 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  48cc33085253d607706e68a67ac98fe2a6abdd3d
Gitweb: http://git.kernel.org/tip/48cc33085253d607706e68a67ac98fe2a6abdd3d
Author: Arnaldo Carvalho de Melo 
AuthorDate: Fri, 28 Jul 2017 12:49:02 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 12:53:05 -0300

perf annotate: Fix storing per line sym_hist_entry

The existing loop incremented the offset while using it as the array
index, when we went to an array of sym_hist_entry instances, we
should've moved the increment to outside of the array element reference,
oops, fix it.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Taeung Song 
Cc: Wang Nan 
Fixes: 461c17f00f40 ("perf annotate: Store the sample period in each histogram 
bucket")
Link: http://lkml.kernel.org/n/tip-s3dm6uyrazlpag3f0psfi...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5125c2b..2dab0e5 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -963,8 +963,9 @@ double disasm__calc_percent(struct annotation *notes, int 
evidx, s64 offset,
u64 period = 0;
 
while (offset < end) {
-   hits += h->addr[offset++].nr_samples;
-   period += h->addr[offset++].period;
+   hits   += h->addr[offset].nr_samples;
+   period += h->addr[offset].period;
+   ++offset;
}
 
if (h->nr_samples) {


[tip:perf/core] perf annotate TUI: Use sym_hist_entry in disasm_line_samples

2017-07-30 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  bb79a232b0881ce47f921a53f40612a9f9996482
Gitweb: http://git.kernel.org/tip/bb79a232b0881ce47f921a53f40612a9f9996482
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 27 Jul 2017 11:24:59 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 12:53:06 -0300

perf annotate TUI: Use sym_hist_entry in disasm_line_samples

Just paving the way to fix --show-total-period in the TUI, i.e. now
we save in struct disasm_line_samples not just the number of samples,
but also the total period.

Based-on-a-patch-by: Taeung Song 
Cc: Jiri Olsa 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/n/tip-1sup5hkwrxocjvrmrmhs7...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index dbe4e63..680fff7 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -17,8 +17,8 @@
 #include 
 
 struct disasm_line_samples {
-   double  percent;
-   u64 nr;
+   doublepercent;
+   struct sym_hist_entry he;
 };
 
 #define IPC_WIDTH 6
@@ -152,7 +152,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
current_entry);
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%6" PRIu64 " ",
-  bdl->samples[i].nr);
+  
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);
@@ -457,7 +457,7 @@ static void annotate_browser__calc_percent(struct 
annotate_browser *browser,
pos->offset,
next ? next->offset : len,
&path, &sample);
-   bpos->samples[i].nr = sample.nr_samples;
+   bpos->samples[i].he = sample;
 
if (max_percent < bpos->samples[i].percent)
max_percent = bpos->samples[i].percent;


[PATCH] KVM: X86: Fix loss of pending INIT due to race

2017-07-30 Thread Wanpeng Li
From: Wanpeng Li 

When SMP VM start, AP may lost INIT because of receiving INIT between
kvm_vcpu_ioctl_x86_get/set_vcpu_events.

   vcpu 0 vcpu 1
   kvm_vcpu_ioctl_x86_get_vcpu_events
 events->smi.latched_init = 0
  send INIT to vcpu1
set vcpu1's pending_events
   kvm_vcpu_ioctl_x86_set_vcpu_events
  if (events->smi.latched_init == 0)
clear INIT in pending_events

This patch fixes it by not touching INIT pending if INIT is not latched 
which in SMM and just restoring the latched INIT after SET_VCPU_EVENTS.

Thanks Peng Hao for the report and original commit message.

Reported-by: Peng Hao 
Cc: Paolo Bonzini 
Cc: Radim Krčmář 
Signed-off-by: Wanpeng Li 
---
 arch/x86/kvm/x86.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1a4c84d..eaca86d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3164,12 +3164,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct 
kvm_vcpu *vcpu,
vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
else
vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK;
-   if (lapic_in_kernel(vcpu)) {
-   if (events->smi.latched_init)
-   set_bit(KVM_APIC_INIT, 
&vcpu->arch.apic->pending_events);
-   else
-   clear_bit(KVM_APIC_INIT, 
&vcpu->arch.apic->pending_events);
-   }
+   if (events->smi.latched_init && lapic_in_kernel(vcpu))
+   set_bit(KVM_APIC_INIT, 
&vcpu->arch.apic->pending_events);
}
 
kvm_make_request(KVM_REQ_EVENT, vcpu);
-- 
2.7.4



[tip:perf/core] perf annotate TUI: Fix column header when toggling period/percent

2017-07-30 Thread tip-bot for Taeung Song
Commit-ID:  f67d395c6e3895c3c8c67c8f7523f6a94d61a82d
Gitweb: http://git.kernel.org/tip/f67d395c6e3895c3c8c67c8f7523f6a94d61a82d
Author: Taeung Song 
AuthorDate: Fri, 28 Jul 2017 12:04:32 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 12:53:08 -0300

perf annotate TUI: Fix column header when toggling period/percent

We have the 't' hotkey to toggle showing either the total period or the
percentage of samples for a given line, but we forgot to toggle as well
the column header, always showing "Percent", even when showing the
period, fix it.

Signed-off-by: Taeung Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: 
http://lkml.kernel.org/r/1501172169-6761-1-git-send-email-treeze.tae...@gmail.com
[ Extracted from a larger patch, s/Event count/Period/g ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 0f4bcc0..46f297a 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -166,7 +166,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
if (!show_title)
ui_browser__write_nstring(browser, " ", pcnt_width);
else
-   ui_browser__printf(browser, "%*s", 7, "Percent");
+   ui_browser__printf(browser, "%*s", 7, 
annotate_browser__opts.show_total_period ? "Period" : "Percent");
}
if (ab->have_cycles) {
if (dl->ipc)


[tip:perf/core] perf annotate TUI: Fix --show-total-period

2017-07-30 Thread tip-bot for Taeung Song
Commit-ID:  29dc267f270a4ad5ae1341e7fdc8539ac7dc907a
Gitweb: http://git.kernel.org/tip/29dc267f270a4ad5ae1341e7fdc8539ac7dc907a
Author: Taeung Song 
AuthorDate: Thu, 27 Jul 2017 11:33:20 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 12:53:06 -0300

perf annotate TUI: Fix --show-total-period

We were showing the number of samples, not the total period, fix it.

Reported-by: Namhyung Kim 
Signed-off-by: Taeung Song 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Martin Liška 
Cc: Milian Wolff 
Cc: Jiri Olsa 
Fixes: 0c4a5bcea460 ("perf annotate: Display total number of samples with 
--show-total-period")
Link: 
http://lkml.kernel.org/r/1500500223-16753-1-git-send-email-treeze.tae...@gmail.com
[ extracted from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 680fff7..c382b1d 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -152,7 +152,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
current_entry);
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%6" PRIu64 " ",
-  
bdl->samples[i].he.nr_samples);
+  bdl->samples[i].he.period);
} else {
ui_browser__printf(browser, "%6.2f ",
   bdl->samples[i].percent);


[tip:perf/core] perf annotate TUI: Set appropriate column width for period/percent

2017-07-30 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  3861c4a49bea432c57d6e7cbd89c8b71ed4445b7
Gitweb: http://git.kernel.org/tip/3861c4a49bea432c57d6e7cbd89c8b71ed4445b7
Author: Arnaldo Carvalho de Melo 
AuthorDate: Fri, 28 Jul 2017 13:19:32 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 13:19:32 -0300

perf annotate TUI: Set appropriate column width for period/percent

Either when we start 'perf annotate' or 'perf report' with
--show-total-period or when we, in the annotate browser, press 't' to
toggle period/percent for the first column, we need to adjust the width
for the 'period' case.

Based-on-a-patch-by: Taeung Song 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-n2np5qcs20u6qjdr9oryg...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 46f297a..80f38da 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -110,7 +110,7 @@ static int annotate_browser__set_jumps_percent_color(struct 
annotate_browser *br
 
 static int annotate_browser__pcnt_width(struct annotate_browser *ab)
 {
-   return 7 * ab->nr_events;
+   return (annotate_browser__opts.show_total_period ? 12 : 7) * 
ab->nr_events;
 }
 
 static int annotate_browser__cycles_width(struct annotate_browser *ab)
@@ -153,7 +153,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
bdl->samples[i].percent,
current_entry);
if (annotate_browser__opts.show_total_period) {
-   ui_browser__printf(browser, "%6" PRIu64 " ",
+   ui_browser__printf(browser, "%11" PRIu64 " ",
   bdl->samples[i].he.period);
} else {
ui_browser__printf(browser, "%6.2f ",
@@ -165,8 +165,10 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
 
if (!show_title)
ui_browser__write_nstring(browser, " ", pcnt_width);
-   else
-   ui_browser__printf(browser, "%*s", 7, 
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+   else {
+   ui_browser__printf(browser, "%*s", pcnt_width,
+  
annotate_browser__opts.show_total_period ? "Period" : "Percent");
+   }
}
if (ab->have_cycles) {
if (dl->ipc)


[tip:perf/core] perf annotate TUI: Clarify calculation of column header widths

2017-07-30 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  bc1e5d60cebb711ca3783a87a969d18db376d357
Gitweb: http://git.kernel.org/tip/bc1e5d60cebb711ca3783a87a969d18db376d357
Author: Arnaldo Carvalho de Melo 
AuthorDate: Thu, 27 Jul 2017 12:05:58 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 12:53:07 -0300

perf annotate TUI: Clarify calculation of column header widths

In commit f8f4aaead579 ("perf annotate: Finally display IPC and cycle
accounting") the 'pcnt_width' variable was abused in a few places to
also include the optional width of the "IPC" and "cycles" columns, while
in other places we stopped using 'pcnt_width' and instead its previous
equation...

Now that we need to tap into annotate_browser__pcnt_width() to consider
if --show-total-period is being used and instead of that hardcoded 7
(strlen("Percent")) we need to use it or strlen("Event count") we need
this properly clarified to avoid having to touch all the (7 * nr_events)
places.

Clarify this by introducing a separate annotate_browser__cycles_width()
to leave the pcnt_width calculate just what its name implies.

Cc: Taeung Song 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Cc: Jiri Olsa 
Cc: Andi Kleen 
Link: http://lkml.kernel.org/n/tip-szgb07t4k5wtvks8nzwkg...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/annotate.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index c382b1d..0f4bcc0 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -110,11 +110,12 @@ static int 
annotate_browser__set_jumps_percent_color(struct annotate_browser *br
 
 static int annotate_browser__pcnt_width(struct annotate_browser *ab)
 {
-   int w = 7 * ab->nr_events;
+   return 7 * ab->nr_events;
+}
 
-   if (ab->have_cycles)
-   w += IPC_WIDTH + CYCLES_WIDTH;
-   return w;
+static int annotate_browser__cycles_width(struct annotate_browser *ab)
+{
+   return ab->have_cycles ? IPC_WIDTH + CYCLES_WIDTH : 0;
 }
 
 static void annotate_browser__write(struct ui_browser *browser, void *entry, 
int row)
@@ -127,7 +128,8 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
 (!current_entry || (browser->use_navkeypressed &&
 !browser->navkeypressed)));
int width = browser->width, printed;
-   int i, pcnt_width = annotate_browser__pcnt_width(ab);
+   int i, pcnt_width = annotate_browser__pcnt_width(ab),
+  cycles_width = annotate_browser__cycles_width(ab);
double percent_max = 0.0;
char bf[256];
bool show_title = false;
@@ -162,7 +164,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
ui_browser__set_percent_color(browser, 0, current_entry);
 
if (!show_title)
-   ui_browser__write_nstring(browser, " ", 7 * 
ab->nr_events);
+   ui_browser__write_nstring(browser, " ", pcnt_width);
else
ui_browser__printf(browser, "%*s", 7, "Percent");
}
@@ -190,7 +192,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
width += 1;
 
if (!*dl->line)
-   ui_browser__write_nstring(browser, " ", width - pcnt_width);
+   ui_browser__write_nstring(browser, " ", width - pcnt_width - 
cycles_width);
else if (dl->offset == -1) {
if (dl->line_nr && annotate_browser__opts.show_linenr)
printed = scnprintf(bf, sizeof(bf), "%-*d ",
@@ -199,7 +201,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
printed = scnprintf(bf, sizeof(bf), "%*s  ",
ab->addr_width, " ");
ui_browser__write_nstring(browser, bf, printed);
-   ui_browser__write_nstring(browser, dl->line, width - printed - 
pcnt_width + 1);
+   ui_browser__write_nstring(browser, dl->line, width - printed - 
pcnt_width - cycles_width + 1);
} else {
u64 addr = dl->offset;
int color = -1;
@@ -256,7 +258,7 @@ static void annotate_browser__write(struct ui_browser 
*browser, void *entry, int
}
 
disasm_line__scnprintf(dl, bf, sizeof(bf), 
!annotate_browser__opts.use_offset);
-   ui_browser__write_nstring(browser, bf, width - pcnt_width - 3 - 
printed);
+   ui_browser__write_nstring(browser, bf, width - pcnt_width - 
cycles_width - 3 - printed);
}
 
if (current_entry)


Re: [PATCH] kvm: x86: fix a race condition result to lost INIT

2017-07-30 Thread Wanpeng Li
2017-07-31 0:24 GMT+08:00 Peng Hao :
> when SMP VM start, AP may lost INIT because of receiving INIT between
> kvm_vcpu_ioctl_x86_get/set_vcpu_events.
>
>vcpu 0 vcpu 1
>kvm_vcpu_ioctl_x86_get_vcpu_events
>events->smi.latched_init=0
>  send INIT to vcpu1
>set vcpu1's pending_events
>kvm_vcpu_ioctl_x86_set_vcpu_events
> events->smi.latched_init == 0
>   clear INIT in pending_events
> I don't think it need set/clear kernel state according to userspace's
> info.
>
> Signed-off-by: Peng Hao 
> ---
>  arch/x86/kvm/x86.c | 6 --
>  1 file changed, 6 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 6c7266f..393a7b7 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3157,12 +3157,6 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct 
> kvm_vcpu *vcpu,
> vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
> else
> vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK;
> -   if (lapic_in_kernel(vcpu)) {
> -   if (events->smi.latched_init)
> -   set_bit(KVM_APIC_INIT, 
> &vcpu->arch.apic->pending_events);

This is not correct, you will lose the INIT after live migration. I
just send out another patch to fix it. Thanks for the report.

Regards,
Wanpeng Li

> -   else
> -   clear_bit(KVM_APIC_INIT, 
> &vcpu->arch.apic->pending_events);
> -   }
> }
>
> kvm_make_request(KVM_REQ_EVENT, vcpu);
> --
> 1.8.3.1
>
>


[tip:perf/core] perf data: Add mmap[2] events to CTF conversion

2017-07-30 Thread tip-bot for Geneviève Bastien
Commit-ID:  f9f6f2a90343c5be3294d1336da055a99c28897d
Gitweb: http://git.kernel.org/tip/f9f6f2a90343c5be3294d1336da055a99c28897d
Author: Geneviève Bastien 
AuthorDate: Thu, 27 Jul 2017 14:12:04 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 16:26:06 -0300

perf data: Add mmap[2] events to CTF conversion

This adds the mmap and mmap2 events to the CTF trace obtained from perf
data.

These events will allow CTF trace visualization tools like Trace Compass
to automatically resolve the symbols of the callchain to the
corresponding function or origin library.

To include those events, one needs to convert with the --all option.
Here follows an output of babeltrace:

  $ sudo perf data convert --all --to-ctf myctftrace
  $ babeltrace ./myctftrace
  [19:00:00.0] (+0.0) perf_mmap2: { cpu_id = 0 },
 { pid = 638, tid = 638, start = 0x7F54AE39E000, filename =
 "/usr/lib/ld-2.25.so" }
  [19:00:00.0] (+0.0) perf_mmap2: { cpu_id = 0 }, { pid =
 638, tid = 638, start = 0x7F54AE565000, filename =
 "/usr/lib/libudev.so.1.6.6" }
  [19:00:00.0] (+0.0) perf_mmap2: { cpu_id = 0 }, { pid =
 638, tid = 638, start = 0x7FFC093EA000, filename = "[vdso]" }

Signed-off-by: Geneviève Bastien 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Francis Deslauriers 
Cc: Julien Desfossez 
Cc: Mathieu Desnoyers 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170727181205.24843-2-gbast...@versatic.net
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/data-convert-bt.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index eeb2590..2346cec 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -76,6 +76,8 @@ struct ctf_writer {
struct bt_ctf_event_class   *comm_class;
struct bt_ctf_event_class   *exit_class;
struct bt_ctf_event_class   *fork_class;
+   struct bt_ctf_event_class   *mmap_class;
+   struct bt_ctf_event_class   *mmap2_class;
 };
 
 struct convert {
@@ -915,6 +917,18 @@ __FUNC_PROCESS_NON_SAMPLE(exit,
__NON_SAMPLE_SET_FIELD(fork, u32, ptid);
__NON_SAMPLE_SET_FIELD(fork, u64, time);
 )
+__FUNC_PROCESS_NON_SAMPLE(mmap,
+   __NON_SAMPLE_SET_FIELD(mmap, u32, pid);
+   __NON_SAMPLE_SET_FIELD(mmap, u32, tid);
+   __NON_SAMPLE_SET_FIELD(mmap, u64_hex, start);
+   __NON_SAMPLE_SET_FIELD(mmap, string, filename);
+)
+__FUNC_PROCESS_NON_SAMPLE(mmap2,
+   __NON_SAMPLE_SET_FIELD(mmap2, u32, pid);
+   __NON_SAMPLE_SET_FIELD(mmap2, u32, tid);
+   __NON_SAMPLE_SET_FIELD(mmap2, u64_hex, start);
+   __NON_SAMPLE_SET_FIELD(mmap2, string, filename);
+)
 #undef __NON_SAMPLE_SET_FIELD
 #undef __FUNC_PROCESS_NON_SAMPLE
 
@@ -1254,6 +1268,19 @@ __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(exit,
__NON_SAMPLE_ADD_FIELD(u64, time);
 )
 
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(mmap,
+   __NON_SAMPLE_ADD_FIELD(u32, pid);
+   __NON_SAMPLE_ADD_FIELD(u32, tid);
+   __NON_SAMPLE_ADD_FIELD(u64_hex, start);
+   __NON_SAMPLE_ADD_FIELD(string, filename);
+)
+
+__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(mmap2,
+   __NON_SAMPLE_ADD_FIELD(u32, pid);
+   __NON_SAMPLE_ADD_FIELD(u32, tid);
+   __NON_SAMPLE_ADD_FIELD(u64_hex, start);
+   __NON_SAMPLE_ADD_FIELD(string, filename);
+)
 #undef __NON_SAMPLE_ADD_FIELD
 #undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS
 
@@ -1271,6 +1298,12 @@ static int setup_non_sample_events(struct ctf_writer *cw,
ret = add_fork_event(cw);
if (ret)
return ret;
+   ret = add_mmap_event(cw);
+   if (ret)
+   return ret;
+   ret = add_mmap2_event(cw);
+   if (ret)
+   return ret;
return 0;
 }
 
@@ -1572,6 +1605,8 @@ int bt_convert__perf2ctf(const char *input, const char 
*path,
c.tool.comm = process_comm_event;
c.tool.exit = process_exit_event;
c.tool.fork = process_fork_event;
+   c.tool.mmap = process_mmap_event;
+   c.tool.mmap2 = process_mmap2_event;
}
 
err = perf_config(convert__config, &c);


[tip:perf/core] perf data: Add callchain to CTF conversion

2017-07-30 Thread tip-bot for Geneviève Bastien
Commit-ID:  a3073c8e590d7baa5a6cb01438cb945c92bfcd91
Gitweb: http://git.kernel.org/tip/a3073c8e590d7baa5a6cb01438cb945c92bfcd91
Author: Geneviève Bastien 
AuthorDate: Thu, 27 Jul 2017 14:12:03 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 16:25:07 -0300

perf data: Add callchain to CTF conversion

The field perf_callchain, if available, is added to the sampling events
during the CTF conversion. It is an array of u64 values.  The
perf_callchain_size field contains the size of the array.

It will allow the analysis of sampling data in trace visualization tools
like Trace Compass. Possible analyses with those data: dynamic
flamegraphs, correlation with other tracing data like a userspace trace.

Here follows a babeltrace CTF output of a trace with callchain:

  $ babeltrace ./myctftrace
  [17:38:45.672760285] (+?.?) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 1, 
perf_callchain_size = 7, perf_callchain = [ [0] = 0xFF80, [1] = 
0x81063EE4, [2] = 0x8100C770, [3] = 0x81006EC6, [4] = 
0x8118245E, [5] = 0x810A9224, [6] = 0x8164A4C6 ] }
  [17:38:45.672777672] (+0.17387) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 1, 
perf_callchain_size = 8, perf_callchain = [ [0] = 0xFF80, [1] = 
0x81063EE4, [2] = 0x8100C770, [3] = 0x81006EC6, [4] = 
0x8118245E, [5] = 0x810A9224, [6] = 0x8164A4C6, [7] = 
0x8164ABAD ] }
  [17:38:45.672786700] (+0.09028) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 70, 
perf_callchain_size = 3, perf_callchain = [ [0] = 0xFF80, [1] = 
0x81063EE4, [2] = 0x8100C770 ] }

Signed-off-by: Geneviève Bastien 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Francis Deslauriers 
Cc: Julien Desfossez 
Cc: Mathieu Desnoyers 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170727181205.24843-1-gbast...@versatic.net
[ Removed PERF_SAMPLE_CALLCHAIN from the TODO list, jolsa ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/data-convert-bt.c | 92 ++-
 1 file changed, 91 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index 3149b70..eeb2590 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -506,6 +506,81 @@ put_len_type:
return ret;
 }
 
+static int
+add_callchain_output_values(struct bt_ctf_event_class *event_class,
+ struct bt_ctf_event *event,
+ struct ip_callchain *callchain)
+{
+   struct bt_ctf_field_type *len_type, *seq_type;
+   struct bt_ctf_field *len_field, *seq_field;
+   unsigned int nr_elements = callchain->nr;
+   unsigned int i;
+   int ret;
+
+   len_type = bt_ctf_event_class_get_field_by_name(
+   event_class, "perf_callchain_size");
+   len_field = bt_ctf_field_create(len_type);
+   if (!len_field) {
+   pr_err("failed to create 'perf_callchain_size' for callchain 
output event\n");
+   ret = -1;
+   goto put_len_type;
+   }
+
+   ret = bt_ctf_field_unsigned_integer_set_value(len_field, nr_elements);
+   if (ret) {
+   pr_err("failed to set field value for perf_callchain_size\n");
+   goto put_len_field;
+   }
+   ret = bt_ctf_event_set_payload(event, "perf_callchain_size", len_field);
+   if (ret) {
+   pr_err("failed to set payload to perf_callchain_size\n");
+   goto put_len_field;
+   }
+
+   seq_type = bt_ctf_event_class_get_field_by_name(
+   event_class, "perf_callchain");
+   seq_field = bt_ctf_field_create(seq_type);
+   if (!seq_field) {
+   pr_err("failed to create 'perf_callchain' for callchain output 
event\n");
+   ret = -1;
+   goto put_seq_type;
+   }
+
+   ret = bt_ctf_field_sequence_set_length(seq_field, len_field);
+   if (ret) {
+   pr_err("failed to set length of 'perf_callchain'\n");
+   goto put_seq_field;
+   }
+
+   for (i = 0; i < nr_elements; i++) {
+   struct bt_ctf_field *elem_field =
+   bt_ctf_field_sequence_get_field(seq_field, i);
+
+   ret = bt_ctf_field_unsigned_integer_set_value(elem_field,
+   ((u64 *)(callchain->ips))[i]);
+
+   bt_ctf_field_put(elem_field);
+   if (ret) {
+   pr_err("failed to set callchain[%d]\n", i);
+   goto put_seq_field;
+   }
+   }
+
+   ret = bt_ctf_event_set_payload(even

[tip:perf/core] perf data: Add doc when no conversion support compiled

2017-07-30 Thread tip-bot for Geneviève Bastien
Commit-ID:  6b7007af728df7258bb60ed73099be3b59b3030e
Gitweb: http://git.kernel.org/tip/6b7007af728df7258bb60ed73099be3b59b3030e
Author: Geneviève Bastien 
AuthorDate: Thu, 27 Jul 2017 14:12:05 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 28 Jul 2017 16:30:45 -0300

perf data: Add doc when no conversion support compiled

This adds documentation on the environment variables needed to the
message telling that no conversion support is compiled in.

Committer testing:

  $ make -C tools/perf install
  $ perf data convert --all --to-ctf myctftrace
  No conversion support compiled in. perf should be compiled with environment 
variables LIBBABELTRACE=1 and LIBBABELTRACE_DIR=/path/to/libbabeltrace/
  $

Signed-off-by: Geneviève Bastien 
Acked-by: Jiri Olsa 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Francis Deslauriers 
Cc: Julien Desfossez 
Cc: Mathieu Desnoyers 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170727181205.24843-3-gbast...@versatic.net
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c
index 0adb5f8..46cd849 100644
--- a/tools/perf/builtin-data.c
+++ b/tools/perf/builtin-data.c
@@ -69,7 +69,7 @@ static int cmd_data_convert(int argc, const char **argv)
};
 
 #ifndef HAVE_LIBBABELTRACE_SUPPORT
-   pr_err("No conversion support compiled in.\n");
+   pr_err("No conversion support compiled in. perf should be compiled with 
environment variables LIBBABELTRACE=1 and 
LIBBABELTRACE_DIR=/path/to/libbabeltrace/\n");
return -1;
 #endif
 


Re: Yes you have standing to sue GRSecurity

2017-07-30 Thread Pavel Machek
On Sat 2017-07-29 22:55:22, David Lang wrote:
> On Sat, 29 Jul 2017, Paul G. Allen wrote:
> 
> >>It's not even clear that there is infringement.  The GPL merely
> >>requires that people who have been distributed copies of GPL'ed code
> >>must not be restricted from further redistribution of the code.  It
> >>does not require that that someone who is distributing it must
> >>available on a public FTP/HTTP server.
> 
> what I have seen reported is that they are adding additional restrictions,
> that if any of their customers redistribute the source, their contract with
> grsecurity is terminated.

Question is if this is legal thing to do.

Because if it is, there could be other "more interesting" abuses of
the GPL (*), and we may want GPLv4 to fix it.

Pavel

(*) Such as: you give us million dollars. You are free to distribute
the sources under the GPL, but if you do, our contract ends and we
will not be returning the million.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH] fbcon: Use background color for margins

2017-07-30 Thread Pavel Machek
Hi!

> Screens that don't have a black border around the active area will have
> ugly black bars for the margin when the text background color is not black.
> This is especially noticeable on an LCD screen (not the backlit kind) when
> the terminal colors are inverted.

Are you sure? It is quite common to have different backgrounds in
different parts of the screen, how it is supposed to work there?

Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: Yes you have standing to sue GRSecurity

2017-07-30 Thread Pavel Machek
Hi!

On Sat 2017-07-29 17:20:52, Paul G. Allen wrote:
> > It's not even clear that there is infringement.  The GPL merely
> > requires that people who have been distributed copies of GPL'ed code
> > must not be restricted from further redistribution of the code.  It
> > does not require that that someone who is distributing it must
> > available on a public FTP/HTTP server.
> >
> > Brad Spengler has asserted that he has not forbidden any of his
> > customers from further redistribution of the code.  Other than his
> > claim of being in compliance with the GPL, I do not personally have
> > any information either suggesting that he is or is not violating the
> > terms of the GNU Public License.
> >
> > Personally, I think I don't think it makes any difference one way or
> > another.  GRSecurity has made themselves irrelevant from the
> > perspective of upstream development.  If someone wants to find some
> > embedded device which is using GRSecurity, and wishes to purchase said
> > device, and then demand access to source code under the terms of the
> > GPL, and then post those sources on some web site, that is all within
> > their right to do.  For the most part, though, it's rarely useful to
> > get dead code posted on a web site.  This is the same reason that
> > people who do drive-by open sourcing of code largely don't make much
> > difference.  You can make a code drop of (for example) Digital's old
> > Tru64 advfs and make it available under an open source license.  But
> > even though it was a very good file system for its time, unless it
> > comes with a community of developers, the code drop will very likely
> > just sit there.
> >
> > So personally, I don't think it's a particularly good use of *my* time
> > to investigate whether or not folks who are responsible for grsecurity
> > are violating the terms of the GPL, and to get involved in a lawsuit.
> > It may be that there is no "there" there, in which case it will be a
> > waste of my time.  And even if we can find proof that GRsecurity has
> > forbidden its customers from redistribution code derived from the
> > Linux kernel, in violation of the GPL, it will be messy, it will
> > enrich a bunch of attorneys --- and at the end of the day we will get
> > a dump of code that probably won't make any real difference to the
> > upstream development of the Linux kernel, since it will probably be
> > based on some ancient 3.18 kernel or some such.
> >
> 
> If there is something to this (that GRSecurity is somehow in violation
> of the GPL), then it would probably be a very good idea for someone
> (the community, Red Hat, etc.) to protect the kernel. From my
> understanding, at least in America, protections under any license or

You probably still have code in the kernel. So you probably can sue
them. I'll have my fingers crossed for you :-), but otherwise don't
expect much help.

Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


perf build: Clarify open-coded header version warning message

2017-07-30 Thread Ingo Molnar
In this patch we changed the header checks:

  perf build: Clarify header version warning message

Unfortunately the header checks were copied to various places and thus the 
message got
out of sync. Fix some of them here.

Note that there's still old, misleading messages remaining in:

  tools/objtool/Makefile: || echo "warning: objtool: x86 instruction decoder 
differs from kernel" >&2 )) || true
  tools/objtool/Makefile: || echo "warning: objtool: orc_types.h differs from 
kernel" >&2 )) || true

here objtool copied the perf message, plus:

 tools/perf/util/intel-pt-decoder/Build: || echo "Warning: Intel PT: x86 
instruction decoder differs from kernel" >&2 )) || true

here the PT code regressed over the original message and only emits a vague 
warning
instead of specific file names...

All of this should be consolidated into tools/Build/ and used in a consistent 
manner.

Signed-off-by: Ingo Molnar 
---
 tools/lib/bpf/Makefile   | 4 ++--
 tools/perf/arch/x86/Makefile | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 1f5300e56b44..e87b5903f4bb 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -156,10 +156,10 @@ all_cmd: $(CMD_TARGETS)
 $(BPF_IN): force elfdep bpfdep
@(test -f ../../../include/uapi/linux/bpf.h -a -f 
../../../include/uapi/linux/bpf.h && ( \
(diff -B ../../include/uapi/linux/bpf.h 
../../../include/uapi/linux/bpf.h >/dev/null) || \
-   echo "Warning: tools/include/uapi/linux/bpf.h differs from kernel" >&2 
)) || true
+   echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' 
differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
@(test -f ../../../include/uapi/linux/bpf_common.h -a -f 
../../../include/uapi/linux/bpf_common.h && ( \
(diff -B ../../include/uapi/linux/bpf_common.h 
../../../include/uapi/linux/bpf_common.h >/dev/null) || \
-   echo "Warning: tools/include/uapi/linux/bpf_common.h differs from 
kernel" >&2 )) || true
+   echo "Warning: Kernel ABI header at 
'tools/include/uapi/linux/bpf_common.h' differs from latest version at 
'include/uapi/linux/bpf_common.h'" >&2 )) || true
$(Q)$(MAKE) $(build)=libbpf
 
 $(OUTPUT)libbpf.so: $(BPF_IN)
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 6c9211b18ec0..9a628a24c5c9 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -20,7 +20,7 @@ _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
 $(header): $(sys)/syscall_64.tbl $(systbl)
@(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
 (diff -B arch/x86/entry/syscalls/syscall_64.tbl 
../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \
-|| echo "Warning: x86_64's syscall_64.tbl differs from kernel" >&2 )) 
|| true
+|| echo "Warning: Kernel ABI header at 
'tools/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 
'arch/x86/entry/syscalls/syscall_64.tbl'" >&2 )) || true
$(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
 
 clean::


tools/include: Sync kernel ABI headers with tooling headers

2017-07-30 Thread Ingo Molnar
Sync up (copy) the following v4.13 kernel headers to the tooling headers:

  arch/arm/include/uapi/asm/kvm.h:
  arch/arm64/include/uapi/asm/kvm.h:
  arch/powerpc/include/uapi/asm/kvm.h:
  arch/s390/include/uapi/asm/kvm.h:

   - KVM ABI extensions, which do not affect perf tooling

  arch/x86/include/asm/cpufeatures.h:
  arch/x86/include/asm/disabled-features.h:

   - New PCID CPU feature on Intel CPUs - does not affect tooling.

I.e. no real changes were needed to resolve the build warnings, just a plain 
copy 
of the latest kernel header version.

Signed-off-by: Ingo Molnar 
---
 tools/arch/arm/include/uapi/asm/kvm.h  |  8 
 tools/arch/arm64/include/uapi/asm/kvm.h|  3 +++
 tools/arch/powerpc/include/uapi/asm/kvm.h  |  6 ++
 tools/arch/s390/include/uapi/asm/kvm.h | 12 
 tools/arch/x86/include/asm/cpufeatures.h   |  2 ++
 tools/arch/x86/include/asm/disabled-features.h |  4 +++-
 6 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/tools/arch/arm/include/uapi/asm/kvm.h 
b/tools/arch/arm/include/uapi/asm/kvm.h
index 5e3c673fa3f4..5db2d4c6a55f 100644
--- a/tools/arch/arm/include/uapi/asm/kvm.h
+++ b/tools/arch/arm/include/uapi/asm/kvm.h
@@ -203,6 +203,14 @@ struct kvm_arch_memory_slot {
 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INTID_MASK 0x3ff
 #define VGIC_LEVEL_INFO_LINE_LEVEL 0
 
+/* Device Control API on vcpu fd */
+#define KVM_ARM_VCPU_PMU_V3_CTRL   0
+#define   KVM_ARM_VCPU_PMU_V3_IRQ  0
+#define   KVM_ARM_VCPU_PMU_V3_INIT 1
+#define KVM_ARM_VCPU_TIMER_CTRL1
+#define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER0
+#define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER1
+
 #define   KVM_DEV_ARM_VGIC_CTRL_INIT   0
 #define   KVM_DEV_ARM_ITS_SAVE_TABLES  1
 #define   KVM_DEV_ARM_ITS_RESTORE_TABLES   2
diff --git a/tools/arch/arm64/include/uapi/asm/kvm.h 
b/tools/arch/arm64/include/uapi/asm/kvm.h
index 70eea2ecc663..9f3ca24bbcc6 100644
--- a/tools/arch/arm64/include/uapi/asm/kvm.h
+++ b/tools/arch/arm64/include/uapi/asm/kvm.h
@@ -232,6 +232,9 @@ struct kvm_arch_memory_slot {
 #define KVM_ARM_VCPU_PMU_V3_CTRL   0
 #define   KVM_ARM_VCPU_PMU_V3_IRQ  0
 #define   KVM_ARM_VCPU_PMU_V3_INIT 1
+#define KVM_ARM_VCPU_TIMER_CTRL1
+#define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER0
+#define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER1
 
 /* KVM_IRQ_LINE irq field index values */
 #define KVM_ARM_IRQ_TYPE_SHIFT 24
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h 
b/tools/arch/powerpc/include/uapi/asm/kvm.h
index 07fbeb927834..8cf8f0c96906 100644
--- a/tools/arch/powerpc/include/uapi/asm/kvm.h
+++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
@@ -60,6 +60,12 @@ struct kvm_regs {
 
 #define KVM_SREGS_E_FSL_PIDn   (1 << 0) /* PID1/PID2 */
 
+/* flags for kvm_run.flags */
+#define KVM_RUN_PPC_NMI_DISP_MASK  (3 << 0)
+#define   KVM_RUN_PPC_NMI_DISP_FULLY_RECOV (1 << 0)
+#define   KVM_RUN_PPC_NMI_DISP_LIMITED_RECOV   (2 << 0)
+#define   KVM_RUN_PPC_NMI_DISP_NOT_RECOV   (3 << 0)
+
 /*
  * Feature bits indicate which sections of the sregs struct are valid,
  * both in KVM_GET_SREGS and KVM_SET_SREGS.  On KVM_SET_SREGS, registers
diff --git a/tools/arch/s390/include/uapi/asm/kvm.h 
b/tools/arch/s390/include/uapi/asm/kvm.h
index 3dd2a1d308dd..69d09c39bbcd 100644
--- a/tools/arch/s390/include/uapi/asm/kvm.h
+++ b/tools/arch/s390/include/uapi/asm/kvm.h
@@ -28,6 +28,7 @@
 #define KVM_DEV_FLIC_CLEAR_IO_IRQ  8
 #define KVM_DEV_FLIC_AISM  9
 #define KVM_DEV_FLIC_AIRQ_INJECT   10
+#define KVM_DEV_FLIC_AISM_ALL  11
 /*
  * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
  * as well as up  to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
@@ -53,6 +54,11 @@ struct kvm_s390_ais_req {
__u16 mode;
 };
 
+struct kvm_s390_ais_all {
+   __u8 simm;
+   __u8 nimm;
+};
+
 #define KVM_S390_IO_ADAPTER_MASK 1
 #define KVM_S390_IO_ADAPTER_MAP 2
 #define KVM_S390_IO_ADAPTER_UNMAP 3
@@ -70,6 +76,7 @@ struct kvm_s390_io_adapter_req {
 #define KVM_S390_VM_TOD1
 #define KVM_S390_VM_CRYPTO 2
 #define KVM_S390_VM_CPU_MODEL  3
+#define KVM_S390_VM_MIGRATION  4
 
 /* kvm attributes for mem_ctrl */
 #define KVM_S390_VM_MEM_ENABLE_CMMA0
@@ -151,6 +158,11 @@ struct kvm_s390_vm_cpu_subfunc {
 #define KVM_S390_VM_CRYPTO_DISABLE_AES_KW  2
 #define KVM_S390_VM_CRYPTO_DISABLE_DEA_KW  3
 
+/* kvm attributes for migration mode */
+#define KVM_S390_VM_MIGRATION_STOP 0
+#define KVM_S390_VM_MIGRATION_START1
+#define KVM_S390_VM_MIGRATION_STATUS   2
+
 /* for KVM_GET_REGS and KVM_SET_REGS */
 struct kvm_regs {
/* general purpose regs for s390 */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h 
b/tools/arch/x86/include/asm/cpufeatures.h
index 2701e5f8145b..14f0f2913364 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/a

Re: [PATCH] drivers/rxe: improve rxe loopback

2017-07-30 Thread Moni Shoua
>> Have you considered using ip_route_output_key() for IPv4 or
>> ip6_route_output() for IPv6 to decide if  this is a loopback?
>> For reference you can check the flow starting at  rdma_resolve_ip()
>>
>
> Hi Moni,
>
> Yes, I had looked into it, but I haven't seen how I can find
> out if the destination IP belongs to the same RXE.
> The loopback flag will give us the "same host"
> confirmation, but not the same rxe instance, right?
>
> Any ideas would be welcomed.
>
> Thanks,
> Marcel
>
Hi Marcel

You are right about that. IFF_LOOPBACK tells you that the source and
destination addresses are on the same host but not necessarily on the
same RXE device.

As Leon mentioned, calling addrX_same_rxe() for each packet seems to
heavy , especially when the use case that justifies it (instead of
calling memcmp() on src and dst) is rare. Do you agree?
If so I think that marking a connection as loopback once is the right approach
For RC/UC - when modified to RTR
For UD - this is harder. IsLoopback() is function of the WQE (or at
least the QP and AH together( but not the QP. I think you can add an
improvement that will work for the majority of cases. This is a sketch
of what I have in mind. Let me know what you think please

1. Add bool last_used_qp to AH structure
2. Add bool is_loopback_with_last_qp to AH structure
3. Set values to AH.last_used_qp and AH.is_loopback_with_last_qp in
post_send() modify_ah(),...
4. Mark WQE as loopback depending on the above


Re: [PATCH V5 net-next 2/8] net: hns3: Add support of the HNAE3 framework

2017-07-30 Thread Leon Romanovsky
On Fri, Jul 28, 2017 at 11:26:46PM +0100, Salil Mehta wrote:
> This patch adds the support of the HNAE3 (Hisilicon Network
> Acceleration Engine 3) framework support to the HNS3 driver.
>
> Framework facilitates clients like ENET(HNS3 Ethernet Driver), RoCE
> and user-space Ethernet drivers (like ODP etc.) to register with HNAE3
> devices and their associated operations.
>
> Signed-off-by: Daode Huang 
> Signed-off-by: lipeng 
> Signed-off-by: Salil Mehta 
> Signed-off-by: Yisen Zhuang 
> ---
> Patch V5: Addressed following comments
>   1. Leon Romanovsky:
>  https://lkml.org/lkml/2017/7/23/67
> Patch V4: Addressed following comments
>   1. Andrew Lunn:
>  https://lkml.org/lkml/2017/6/17/233
>  https://lkml.org/lkml/2017/6/18/105
>   2. Bo Yu:
>  https://lkml.org/lkml/2017/6/18/112
>   3. Stephen Hamminger:
>  https://lkml.org/lkml/2017/6/19/778
> Patch V3: Addressed below comments
>   1. Andrew Lunn:
>  https://lkml.org/lkml/2017/6/13/1025
> Patch V2: No change
> Patch V1: Initial Submit
> ---
>  drivers/net/ethernet/hisilicon/hns3/hnae3.c | 319 
>  drivers/net/ethernet/hisilicon/hns3/hnae3.h | 444 
> 
>  2 files changed, 763 insertions(+)
>  create mode 100644 drivers/net/ethernet/hisilicon/hns3/hnae3.c
>  create mode 100644 drivers/net/ethernet/hisilicon/hns3/hnae3.h
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c 
> b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
> new file mode 100644
> index 000..d28b69d
> --- /dev/null
> +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
> @@ -0,0 +1,319 @@
> +/*
> + * Copyright (c) 2016-2017 Hisilicon Limited.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "hnae3.h"
> +
> +static LIST_HEAD(hnae3_ae_algo_list);
> +static LIST_HEAD(hnae3_client_list);
> +static LIST_HEAD(hnae3_ae_dev_list);
> +
> +/* we are keeping things simple and using single lock for all the
> + * list. This is a non-critical code so other updations, if happen
> + * in parallel, can wait.
> + */
> +static DEFINE_MUTEX(hnae3_common_lock);
> +
> +static bool hnae3_client_match(enum hnae3_client_type client_type,
> +enum hnae3_dev_type dev_type)
> +{
> + if (dev_type == HNAE3_DEV_KNIC) {
> + switch (client_type) {
> + case HNAE3_CLIENT_KNIC:
> + case HNAE3_CLIENT_ROCE:
> + return true;
> + default:
> + return false;
> + }
> + } else if (dev_type == HNAE3_DEV_UNIC) {
> + switch (client_type) {
> + case HNAE3_CLIENT_UNIC:
> + return true;
> + default:
> + return false;
> + }
> + } else {
> + return false;
> + }
> +}

Slightly compact version:

static bool hnae3_client_match(enum hnae3_client_type client_type,
   enum hnae3_dev_type dev_type)
{
if (dev_type == HNAE3_DEV_KNIC &&
client_type == HNAE3_CLIENT_KNIC || client_type == 
HNAE3_CLIENT_ROCE)
return true;
if (dev_type == HNAE3_DEV_UNIC && client_type == HNAE3_CLIENT_UNIC)
return true;
return false;
}


> +
> +static int hnae3_match_n_instantiate(struct hnae3_client *client,
> +  struct hnae3_ae_dev *ae_dev,
> +  bool is_reg, bool *matched)
> +{
> + int ret;
> +
> + *matched = false;
> +
> + /* check if this client matches the type of ae_dev */
> + if (!(hnae3_client_match(client->type, ae_dev->dev_type) &&
> +   hnae_get_bit(ae_dev->flag, HNAE3_DEV_INITED_B))) {
> + return 0;
> + }
> + /* there is a match of client and dev */
> + *matched = true;
> +
> + if (!(ae_dev->ops && ae_dev->ops->init_client_instance &&
> +   ae_dev->ops->uninit_client_instance)) {
> + dev_err(&ae_dev->pdev->dev,
> + "ae_dev or client init/uninit ops are null\n");
> + return -EOPNOTSUPP;
> + }

You should check it during registration phase, IMHO in other places it is
safe to assume that you have init/uninit functions.

> +
> + /* now, (un-)instantiate client by calling lower layer */
> + if (is_reg) {
> + ret = ae_dev->ops->init_client_instance(client, ae_dev);
> + if (ret)
> + dev_err(&ae_dev->pdev->dev,
> + "fail to instantiate client\n");
> + return ret;
> + }
> +
> + ae_dev->ops->uninit_client_instance(client, ae_dev);
> + return 0;
> +}
> +
> +int hnae3_register_client(struct hnae3_client *client

Re: [PATCH V2 net-next 20/21] net-next/hinic: Add ethtool and stats

2017-07-30 Thread Aviad Krawczyk
Hi,

I saw that netif_err is more common in code, is it preferred on netdev_err?
What is the preferred style, netif_ or netdev_?

Best Regards,
Aviad

On 7/27/2017 1:33 AM, Andrew Lunn wrote:
> On Wed, Jul 19, 2017 at 03:36:28PM +0300, Aviad Krawczyk wrote:
>> Hi Joe,
>>
>> I tried to be consistent with the comments before, that requested
>> that we will use dev_err exclude some special cases for use netif.
>>
>> We will replace the dev_err(&netdev->dev,.. to netdev_err in the
>> next fix.
> 
> netdev_err() should be used when possible. You just have to be careful
> in the probe() function, before netdev exists and you get "(NULL
> net_device):" or before it is registered and you get "(unnamed
> net_device)" instead of "eth42" etc.
> 
> Andrew
> 
> .
> 



Re: [PATCH v2] f2fs: support journelled quota

2017-07-30 Thread Chao Yu
Hi Jaegeuk,

On 2017/7/30 15:35, Jaegeuk Kim wrote:
> Hi Chao,
> 
> When I add this patch, xfstests/fsstress are giving some weird kernel hang
> or panic now. Without only this patch, I can't see any problem. Can you review
> this patch one more time in terms of memory and lock usages.

Recently, in last 4.13-rc1 kernel, I have the same issue when testing quota
patches with zram device as backend storage. Did you test with zram? If so,
could you apply patch in below link and retest?

https://patchwork.kernel.org/patch/9861253/

Anyway, let me double check this patch first.

Thanks,

> 
> I'm doing xfstests without quota though.
> 
> Thanks,
> 
> On 07/26, Chao Yu wrote:
>> From: Chao Yu 
>>
>> This patch supports to enable f2fs to accept quota information through
>> mount option:
>> - {usr,grp,prj}jquota=
>> - jqfmt=
>>
>> Then, in ->mount flow, we can recover quota file during log replaying,
>> by this, journelled quota can be supported.
>>
>> Signed-off-by: Chao Yu 
>> ---
>> v2: fix warning in f2fs_remount.
>>  Documentation/filesystems/f2fs.txt |   9 ++
>>  fs/f2fs/f2fs.h |   7 +
>>  fs/f2fs/recovery.c |  25 +++-
>>  fs/f2fs/super.c| 284 
>> +
>>  4 files changed, 322 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/filesystems/f2fs.txt 
>> b/Documentation/filesystems/f2fs.txt
>> index b39d189c9677..b87067683297 100644
>> --- a/Documentation/filesystems/f2fs.txt
>> +++ b/Documentation/filesystems/f2fs.txt
>> @@ -165,6 +165,15 @@ io_bits=%u Set the bit size of write IO 
>> requests. It should be set
>>  usrquota   Enable plain user disk quota accounting.
>>  grpquota   Enable plain group disk quota accounting.
>>  prjquota   Enable plain project quota accounting.
>> +usrjquota=   Appoint specified file and type during mount, so 
>> that quota
>> +grpjquota=   information can be properly updated during recovery 
>> flow,
>> +prjjquota=   : must be in root directory;
>> +jqfmt= : [vfsold,vfsv0,vfsv1].
>> +offusrjquota   Turn off user journelled quota.
>> +offgrpjquota   Turn off group journelled quota.
>> +offprjjquota   Turn off project journelled quota.
>> +quota  Enable plain user disk quota accounting.
>> +noquotaDisable all plain disk quota option.
>>  daxUse direct access (no page cache). See
>> Documentation/filesystems/dax.txt.
>>  
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index c57b83f7b108..a6259660e401 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -97,6 +97,7 @@ extern char *fault_name[FAULT_MAX];
>>  #else
>>  #define F2FS_MOUNT_DAX  0
>>  #endif
>> +#define F2FS_MOUNT_QUOTA0x0080
>>  
>>  #define clear_opt(sbi, option)  ((sbi)->mount_opt.opt &= 
>> ~F2FS_MOUNT_##option)
>>  #define set_opt(sbi, option)((sbi)->mount_opt.opt |= 
>> F2FS_MOUNT_##option)
>> @@ -1100,6 +1101,12 @@ struct f2fs_sb_info {
>>  #ifdef CONFIG_F2FS_FAULT_INJECTION
>>  struct f2fs_fault_info fault_info;
>>  #endif
>> +
>> +#ifdef CONFIG_QUOTA
>> +/* Names of quota files with journalled quota */
>> +char *s_qf_names[MAXQUOTAS];
>> +int s_jquota_fmt;   /* Format of quota to use */
>> +#endif
>>  };
>>  
>>  #ifdef CONFIG_F2FS_FAULT_INJECTION
>> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
>> index 2d9b8182691f..998568ec9b06 100644
>> --- a/fs/f2fs/recovery.c
>> +++ b/fs/f2fs/recovery.c
>> @@ -69,20 +69,34 @@ static struct fsync_inode_entry *get_fsync_inode(struct 
>> list_head *head,
>>  }
>>  
>>  static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi,
>> -struct list_head *head, nid_t ino)
>> +struct list_head *head, nid_t ino, bool quota_inode)
>>  {
>>  struct inode *inode;
>>  struct fsync_inode_entry *entry;
>> +int err;
>>  
>>  inode = f2fs_iget_retry(sbi->sb, ino);
>>  if (IS_ERR(inode))
>>  return ERR_CAST(inode);
>>  
>> +err = dquot_initialize(inode);
>> +if (err)
>> +goto err_out;
>> +
>> +if (quota_inode) {
>> +err = dquot_alloc_inode(inode);
>> +if (err)
>> +goto err_out;
>> +}
>> +
>>  entry = f2fs_kmem_cache_alloc(fsync_entry_slab, GFP_F2FS_ZERO);
>>  entry->inode = inode;
>>  list_add_tail(&entry->list, head);
>>  
>>  return entry;
>> +err_out:
>> +iput(inode);
>> +return ERR_PTR(err);
>>  }
>>  
>>  static void del_fsync_inode(struct fsync_inode_entry *entry)
>> @@ -107,7 +121,8 @@ static int recover_dentry(struct inode *inode, struct 
>> page *ipage,
>>  
>>  entry = get_fsync_inode(dir_list, pino);
>>  if (!entry) {
>> -entry = add_fsync_inode(F2FS_I_SB(inode), dir_list, pino);
>> +entry = ad

Re: Yes you have standing to sue GRSecurity - Yes there is a blatant violation

2017-07-30 Thread nisus

On 2017-07-29 20:07, Theodore Ts'o wrote:


It's not even clear that there is infringement.  The GPL merely...


Yes it is.

Here's a posting from before that explains it:



GPL v2
Section 6 states simply
"You may not impose any further restrictions on the recipients' exercise 
of the rights granted herein."



From GRSecurity's "Stable Patch Agreement":

"Notwithstanding these rights and obligations, the User acknowledges 
that redistribution of the provided stable patches or changelogs outside 
of the explicit obligations under the GPL to User's customers will 
result in termination of access to future updates of grsecurity stable 
patches and changelogs."


Clear as day. What some lay people do not understand is that the terms 
in section 6 are governing what agreements and actions the distributee 
can take regarding furthur distributees, in reality, in the flesh.


Here the ACTIONS of GRSecurity are to RESTRICT the exercise of the 
redistribution rights of the further distributee.


This is an action prohibited by the terms offered by the linux-rights 
holders, and they have written as another term that the permission they 
give to use their property is revoked upon violation of their terms.


Very simple.

(Someone previously said on another thread:)
And none are imposed. However, you are given the option to agree to 
them. Clear as day.


The proffering of the additional restrictive terms is in and of itself a 
violation of section 2. You are holding the clients to an additional 
restriction and enforcing this restriction via a threat to suspend 
business relationships.


(YES YOU HAVE IMPOSED AN ADDITIONAL RESTRICTION)


Here's it put another way:


Correction to common
programmer's misunderstanding


They don't have to add a term to the GPL per-se as the GPL is not a 
party to the agreement, it is "merely" the (not-fully integrated) 
writing describing the license that the rights-holders have granted 
GRSecurity et al.


That is: the GPL in-part describes the license grant that the linux 
rights-holders have extended.
(There may be other parts described elsewhere, even verbally or through 
a course of business dealings or relationship)
(Copyright law, being quite bare on it's own, often borrows much from 
contract law)


Licensees must extend the same grant to Distributees, they cannot add an 
additional term to that relationship.

GRSecurity has added such a term.

They did not pen it into the text of the GPL.
But, according to existing testimony they did make it clear that 
redistribution will not be tolerated.
It is unknown if an electronic or hard copy of this additional term 
controlling the relationship exists,
or whether it was a verbal agreement, or even some implicit 
understanding. Any which way: it is a forbidden additional

term.


lsipc(1) triggers general protection fault in sysvipc_shm_proc_show() on v4.13-rc2+

2017-07-30 Thread Dominik Brodowski
Kees, Manfred,

on Linus' most recent kernel (v4.13-rc2+, git head 0a07b238e5f48), lsipc(1)
works as expected in initramfs and before gnome starts up. Afterwards,
running lsipc as user(!) results in the following general protection fault
and a quite unusable system:

[  183.018415] general protection fault:  [#1] PREEMPT SMP
[  183.018486] Modules linked in:
[  183.018521] CPU: 2 PID: 1964 Comm: lsipc Not tainted 4.13.0-rc2+ #2
[  183.018575] Hardware name: Dell Inc. XPS 13 9343/0TM99H, BIOS A11 12/08/2016
[  183.018636] task: 9f0651708000 task.stack: a8d3837d
[  183.018692] RIP: 0010:shm_add_rss_swap.isra.1+0x13/0xa0
[  183.018738] RSP: 0018:a8d3837d3d78 EFLAGS: 00010246
[  183.018785] RAX: 6b6b6b6b6b6b6b6b RBX: 9f065c29cc70 RCX: 
[  183.018845] RDX: a8d3837d3de0 RSI: a8d3837d3dd8 RDI: 9f065c29cd50
[  183.018905] RBP: a8d3837d3d98 R08:  R09: 9f065c29cc70
[  183.018965] R10: 0040 R11:  R12: 8bc5b9a0
[  183.019026] R13: 9f063838a280 R14: 9f065c29cc70 R15: 9f068bcecaa0
[  183.019088] FS:  7cec9dce2700() GS:9f069f50() 
knlGS:
[  183.019156] CS:  0010 DS:  ES:  CR0: 80050033
[  183.019206] CR2: 7ffe4e7a8ff8 CR3: 00020b9ca000 CR4: 003406e0
[  183.019265] Call Trace:
[  183.019294]  sysvipc_shm_proc_show+0x5e/0x150
[  183.019338]  ? _raw_spin_lock+0x17/0x40
[  183.019376]  ? sysvipc_find_ipc+0xbc/0xf0
[  183.019416]  sysvipc_proc_show+0x1a/0x30
[  183.019456]  seq_read+0x2e9/0x3f0
[  183.019492]  proc_reg_read+0x42/0x70
[  183.019528]  __vfs_read+0x18/0x40
[  183.019562]  vfs_read+0x8e/0x110
[  183.019595]  SyS_read+0x55/0xc0
[  183.019629]  entry_SYSCALL_64_fastpath+0x18/0xa8
[  183.019671] RIP: 0033:0x7cec9d5fcb90
[  183.019703] RSP: 002b:7ffe4e7a97d8 EFLAGS: 0246 ORIG_RAX: 

[  183.019769] RAX: ffda RBX: 07e254b1a221 RCX: 7cec9d5fcb90
[  183.019829] RDX: 0400 RSI: 07e255712020 RDI: 0003
[  183.019890] RBP: 7cec9d8ba588 R08: 0003 R09: 007c
[  183.019950] R10: 0040 R11: 0246 R12: 7cec9d8b9820
[  183.020010] R13: 0011 R14: 7ffe4e7a95b0 R15: 7ffe4e7a95b0
[  183.020071] Code: 7f 18 48 89 e5 e8 5e ff ff ff 85 c0 75 02 5d c3 0f ff 5d 
c3 0f 1f 40 00 0f 1f 44 00 00 55 48 89 e5 41 56 41 55 41 54 53 48 8b 07 <4c> 8b 
60 08 48 8b 40 68 48 3d 80 13 47 8b 74 08 48 3d 00 15 45 
[  183.020290] RIP: shm_add_rss_swap.isra.1+0x13/0xa0 RSP: a8d3837d3d78
[  183.042734] ---[ end trace c5a8076d8f19909f ]---
[  183.042740] note: lsipc[1964] exited with preempt_count 1

Thanks,
Dominik


signature.asc
Description: PGP signature


[PATCH -tip v8 0/4] kprobes related bugfix

2017-07-30 Thread Masami Hiramatsu
Hi,

Here are the series of patches to fix kprobes not
to optimize on the functions in irqentry text ([4/4]).
To check the irqentry text always, [3/4] makes irqentry
text section unconditional.

This involves some other cleanups on h8300, xtensa,
because those sources declare section start/end symbol
as single characters, but generic sections.h declares
it as character arrays. So it leads build errors if
we apply [3/4].

Thank you,

---

Masami Hiramatsu (4):
  h8300: mark _stext and _etext as char-arrays, not single char
  xtensa: mark _stext and _end as char-arrays, not single char
  irq: Make irqentry text section unconditional
  [BUGFIX] kprobes/x86: Do not jump-optimize kprobes on irq entry code


 arch/arm/include/asm/traps.h  |7 ---
 arch/arm64/include/asm/traps.h|7 ---
 arch/h8300/include/asm/traps.h|6 +++---
 arch/x86/entry/entry_64.S |9 ++---
 arch/x86/kernel/kprobes/opt.c |9 ++---
 arch/x86/kernel/unwind_frame.c|2 --
 arch/xtensa/kernel/setup.c|6 +++---
 include/asm-generic/sections.h|4 
 include/asm-generic/vmlinux.lds.h |8 
 include/linux/interrupt.h |   14 +-
 10 files changed, 19 insertions(+), 53 deletions(-)

--
Masami Hiramatsu


Re: [PATCH] f2fs: provide f2fs_balance_fs to __write_data_page for dentry pages

2017-07-30 Thread Chao Yu
Hi Jaegeuk,

On 2017/7/30 15:31, Jaegeuk Kim wrote:
> On 07/29, Yunlong Song wrote:
>> f2fs_balance_fs of dentry pages is skipped in __write_data_page due to 
>> deadlock
>> of gc_mutex in write_checkpoint flow. This patch enables f2fs_balance_fs for
>> normal dentry page writeback to ensure there are always enough free segments.
> 
> Sorry, by the way, why do we need to do this? I subtly thought that dirty node
> pages can be produce by redirtied inodes from what we've not covered through
> filesystem calls. But, in dentry pages, we're controlling the number of dirty
> pages, and calling f2fs_balance_fs in each directory operations.

IMO, writebacking dentry page can redirty dnode page which may be clean 
previously,
so it will be more safe to call f2fs_balance_fs to make sure dirty metadatas of
filesystem didn't exceed the threshold.

Thanks,

> 
> Chao?
> 
> Thanks,
> 
>>
>> Reported-by: Chao Yu 
>> Signed-off-by: Yunlong Song 
>> ---
>>  fs/f2fs/checkpoint.c |  2 +-
>>  fs/f2fs/data.c   | 67 
>> +---
>>  fs/f2fs/f2fs.h   |  1 +
>>  3 files changed, 61 insertions(+), 9 deletions(-)
>>
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index 3c84a25..2882878 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -904,7 +904,7 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum 
>> inode_type type)
>>  if (inode) {
>>  unsigned long cur_ino = inode->i_ino;
>>  
>> -filemap_fdatawrite(inode->i_mapping);
>> +f2fs_filemap_fdatawrite(inode->i_mapping, is_dir);
>>  iput(inode);
>>  /* We need to give cpu to another writers. */
>>  if (ino == cur_ino) {
>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>> index aefc2a5..ed7efa5 100644
>> --- a/fs/f2fs/data.c
>> +++ b/fs/f2fs/data.c
>> @@ -1475,7 +1475,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
>>  }
>>  
>>  static int __write_data_page(struct page *page, bool *submitted,
>> -struct writeback_control *wbc)
>> +struct writeback_control *wbc, bool do_balance)
>>  {
>>  struct inode *inode = page->mapping->host;
>>  struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>> @@ -1578,7 +1578,7 @@ static int __write_data_page(struct page *page, bool 
>> *submitted,
>>  }
>>  
>>  unlock_page(page);
>> -if (!S_ISDIR(inode->i_mode))
>> +if (do_balance)
>>  f2fs_balance_fs(sbi, need_balance_fs);
>>  
>>  if (unlikely(f2fs_cp_error(sbi))) {
>> @@ -1602,7 +1602,7 @@ static int __write_data_page(struct page *page, bool 
>> *submitted,
>>  static int f2fs_write_data_page(struct page *page,
>>  struct writeback_control *wbc)
>>  {
>> -return __write_data_page(page, NULL, wbc);
>> +return __write_data_page(page, NULL, wbc, true);
>>  }
>>  
>>  /*
>> @@ -1611,7 +1611,7 @@ static int f2fs_write_data_page(struct page *page,
>>   * warm/hot data page.
>>   */
>>  static int f2fs_write_cache_pages(struct address_space *mapping,
>> -struct writeback_control *wbc)
>> +struct writeback_control *wbc, bool 
>> do_balance)
>>  {
>>  int ret = 0;
>>  int done = 0;
>> @@ -1701,7 +1701,7 @@ static int f2fs_write_cache_pages(struct address_space 
>> *mapping,
>>  if (!clear_page_dirty_for_io(page))
>>  goto continue_unlock;
>>  
>> -ret = __write_data_page(page, &submitted, wbc);
>> +ret = __write_data_page(page, &submitted, wbc, 
>> do_balance);
>>  if (unlikely(ret)) {
>>  /*
>>   * keep nr_to_write, since vfs uses this to
>> @@ -1756,8 +1756,8 @@ static int f2fs_write_cache_pages(struct address_space 
>> *mapping,
>>  return ret;
>>  }
>>  
>> -static int f2fs_write_data_pages(struct address_space *mapping,
>> -struct writeback_control *wbc)
>> +static int _f2fs_write_data_pages(struct address_space *mapping,
>> +struct writeback_control *wbc, bool do_balance)
>>  {
>>  struct inode *inode = mapping->host;
>>  struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>> @@ -1794,7 +1794,7 @@ static int f2fs_write_data_pages(struct address_space 
>> *mapping,
>>  goto skip_write;
>>  
>>  blk_start_plug(&plug);
>> -ret = f2fs_write_cache_pages(mapping, wbc);
>> +ret = f2fs_write_cache_pages(mapping, wbc, do_balance);
>>  blk_finish_plug(&plug);
>>  
>>  if (wbc->sync_mode == WB_SYNC_ALL)
>> @@ -1813,6 +1813,57 @@ static int f2fs_write_data_pages(struct address_space 
>> *mapping,
>>  return 0;
>>  }
>>  
>> +static int f2fs_write_data_pages(struct address_space *mapping,
>> +struct writeback_control *wbc)
>> +{
>> +return  _f2fs_write_data_

[PATCH -tip v8 1/4] h8300: mark _stext and _etext as char-arrays, not single char

2017-07-30 Thread Masami Hiramatsu
Mark _stext and _etext as character arrays instead of
single character, as same as include/asm-generic/sections.h
does.

Signed-off-by: Masami Hiramatsu 
---
 arch/h8300/include/asm/traps.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/h8300/include/asm/traps.h b/arch/h8300/include/asm/traps.h
index 15e701130b27..1c5a30ec2df8 100644
--- a/arch/h8300/include/asm/traps.h
+++ b/arch/h8300/include/asm/traps.h
@@ -33,9 +33,9 @@ extern unsigned long *_interrupt_redirect_table;
 #define TRAP2_VEC 10
 #define TRAP3_VEC 11
 
-extern char _start, _etext;
+extern char _start[], _etext[];
 #define check_kernel_text(addr) \
-   ((addr >= (unsigned long)(&_start)) && \
-(addr <  (unsigned long)(&_etext)) && !(addr & 1))
+   ((addr >= (unsigned long)(_start)) && \
+(addr <  (unsigned long)(_etext)) && !(addr & 1))
 
 #endif /* _H8300_TRAPS_H */



[PATCH -tip v8 2/4] xtensa: mark _stext and _end as char-arrays, not single char

2017-07-30 Thread Masami Hiramatsu
Mark _stext and _end as character arrays instead of single
character, as same as include/asm-generic/sections.h does.

Signed-off-by: Masami Hiramatsu 
---
 arch/xtensa/kernel/setup.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index 33bfa5270d95..08175df7a69e 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -273,8 +273,8 @@ void __init init_arch(bp_tag_t *bp_start)
  * Initialize system. Setup memory and reserve regions.
  */
 
-extern char _end;
-extern char _stext;
+extern char _end[];
+extern char _stext[];
 extern char _WindowVectors_text_start;
 extern char _WindowVectors_text_end;
 extern char _DebugInterruptVector_literal_start;
@@ -333,7 +333,7 @@ void __init setup_arch(char **cmdline_p)
}
 #endif
 
-   mem_reserve(__pa(&_stext), __pa(&_end));
+   mem_reserve(__pa(_stext), __pa(_end));
 
 #ifdef CONFIG_VECTORS_OFFSET
mem_reserve(__pa(&_WindowVectors_text_start),



Re: Yes you have standing to sue GRSecurity - Yes there is a blatant violation

2017-07-30 Thread nisus
Or as Bruce Perens put it (and yes Bruce Perens is correct, and yes I am 
an attorney)



Bruce Perens wrote:

"Currently, Grsecurity is a commercial product and is distributed only 
to paying customers. Under their Stable Patch Access Agreement, 
customers are warned that if they redistribute the Grsecurity patch, as 
would be their right under the GPL, that they will be assessed a 
penalty: they will no longer be allowed to be customers, and will not be 
granted access to any further versions of Grsecurity. GPL version 2 
section 6 explicitly prohibits the addition of terms such as this 
redistribution prohibition."


"By operating under their policy of terminating customer relations upon 
distribution of their GPL-licensed software, Open Source Security Inc., 
the owner of Grsecurity, creates an expectation  that the customer’s 
business will be damaged by losing access to support and later versions 
of the product, if that customer exercises their re-distribution right 
under the GPL license. Grsecurity’s Stable Patch Access Agreement adds a 
term to the GPL prohibiting distribution or creating a penalty for 
distribution. GPL section 6 specifically prohibits any addition of 
terms.  Thus, the GPL license, which allows Grsecurity to create its 
derivative work of the Linux kernel, terminates, and the copyright of 
the Linux Kernel is infringed. The GPL does not apply when Grsecurity 
first ships the work to the customer, and thus the customer has paid for 
an unlicensed infringing derivative work of the Linux kernel developers 
with all rights reserved.  The contract from the Linux kernel developers 
to both Grsecurity and the customer which is inherent in the GPL is 
breached."



perens.com/blog/2017/06/28/warning-grsecurity-potential-contributory-infringement-risk-for-customers/

Stable patch agreement:
perens.com/wp-content/uploads/2017/06/grsecstablepatchaccessagreement_additionalterms.pdf



Again, Yes I am an attorney, yes Bruce Perens is correct, Yes I know 
what I'm talking about in this field more than you American Programmers, 
no you do not know what you are talking about if you have not studied 
law.




[PATCH -tip v8 3/4] irq: Make irqentry text section unconditional

2017-07-30 Thread Masami Hiramatsu
Generate irqentry and softirqentry text sections without
any configs. This will add above extra sections, but
no performace impact.

Signed-off-by: Masami Hiramatsu 
Suggested-by: Ingo Molnar 
---
 arch/arm/include/asm/traps.h  |7 ---
 arch/arm64/include/asm/traps.h|7 ---
 arch/x86/entry/entry_64.S |9 ++---
 arch/x86/kernel/unwind_frame.c|2 --
 include/asm-generic/sections.h|4 
 include/asm-generic/vmlinux.lds.h |8 
 include/linux/interrupt.h |   14 +-
 7 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/arch/arm/include/asm/traps.h b/arch/arm/include/asm/traps.h
index f555bb3664dc..683d9230984a 100644
--- a/arch/arm/include/asm/traps.h
+++ b/arch/arm/include/asm/traps.h
@@ -18,7 +18,6 @@ struct undef_hook {
 void register_undef_hook(struct undef_hook *hook);
 void unregister_undef_hook(struct undef_hook *hook);
 
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
 static inline int __in_irqentry_text(unsigned long ptr)
 {
extern char __irqentry_text_start[];
@@ -27,12 +26,6 @@ static inline int __in_irqentry_text(unsigned long ptr)
return ptr >= (unsigned long)&__irqentry_text_start &&
   ptr < (unsigned long)&__irqentry_text_end;
 }
-#else
-static inline int __in_irqentry_text(unsigned long ptr)
-{
-   return 0;
-}
-#endif
 
 static inline int in_exception_text(unsigned long ptr)
 {
diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h
index 02e9035b0685..47a9066f7c86 100644
--- a/arch/arm64/include/asm/traps.h
+++ b/arch/arm64/include/asm/traps.h
@@ -37,18 +37,11 @@ void unregister_undef_hook(struct undef_hook *hook);
 
 void arm64_notify_segfault(struct pt_regs *regs, unsigned long addr);
 
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
 static inline int __in_irqentry_text(unsigned long ptr)
 {
return ptr >= (unsigned long)&__irqentry_text_start &&
   ptr < (unsigned long)&__irqentry_text_end;
 }
-#else
-static inline int __in_irqentry_text(unsigned long ptr)
-{
-   return 0;
-}
-#endif
 
 static inline int in_exception_text(unsigned long ptr)
 {
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index aa58155187c5..5e41396efbbf 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -766,13 +766,8 @@ apicinterrupt3 \num trace(\sym) smp_trace(\sym)
 #endif
 
 /* Make sure APIC interrupt handlers end up in the irqentry section: */
-#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
-# define PUSH_SECTION_IRQENTRY .pushsection .irqentry.text, "ax"
-# define POP_SECTION_IRQENTRY  .popsection
-#else
-# define PUSH_SECTION_IRQENTRY
-# define POP_SECTION_IRQENTRY
-#endif
+#define PUSH_SECTION_IRQENTRY  .pushsection .irqentry.text, "ax"
+#define POP_SECTION_IRQENTRY   .popsection
 
 .macro apicinterrupt num sym do_sym
 PUSH_SECTION_IRQENTRY
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 7574ef5f16ec..d145a0b1f529 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -84,10 +84,8 @@ static bool in_entry_code(unsigned long ip)
if (addr >= __entry_text_start && addr < __entry_text_end)
return true;
 
-#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
if (addr >= __irqentry_text_start && addr < __irqentry_text_end)
return true;
-#endif
 
return false;
 }
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 532372c6cf15..e5da44eddd2f 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -27,6 +27,8 @@
  * __kprobes_text_start, __kprobes_text_end
  * __entry_text_start, __entry_text_end
  * __ctors_start, __ctors_end
+ * __irqentry_text_start, __irqentry_text_end
+ * __softirqentry_text_start, __softirqentry_text_end
  */
 extern char _text[], _stext[], _etext[];
 extern char _data[], _sdata[], _edata[];
@@ -39,6 +41,8 @@ extern char __per_cpu_load[], __per_cpu_start[], 
__per_cpu_end[];
 extern char __kprobes_text_start[], __kprobes_text_end[];
 extern char __entry_text_start[], __entry_text_end[];
 extern char __start_rodata[], __end_rodata[];
+extern char __irqentry_text_start[], __irqentry_text_end[];
+extern char __softirqentry_text_start[], __softirqentry_text_end[];
 
 /* Start and end of .ctors section - used for constructor calls. */
 extern char __ctors_start[], __ctors_end[];
diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index fffc9bdae025..438b014c192f 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -483,25 +483,17 @@
*(.entry.text)  \
VMLINUX_SYMBOL(__entry_text_end) = .;
 
-#if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN)
 #define IRQENTRY_TEXT  \
ALI

[PATCH -tip v8 4/4] [BUGFIX] kprobes/x86: Do not jump-optimize kprobes on irq entry code

2017-07-30 Thread Masami Hiramatsu
Since the kernel segment registers are not prepared at the
entry of irq-entry code, if a kprobe on such code is
jump-optimized, accessing per-cpu variables may cause
kernel panic.
However, if the kprobe is not optimized, it kicks int3
exception and set segment registers correctly.

This checks probe-address and if it is in irq-entry code,
it prohibits optimizing such kprobes. This means we can
continuously probing such interrupt handlers by kprobes
but it is not optimized anymore.

Signed-off-by: Masami Hiramatsu 
Reported-by: Francis Deslauriers 
Tested-by: Francis Deslauriers 
---
 arch/x86/kernel/kprobes/opt.c |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index 69ea0bc1cfa3..4f98aad38237 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -251,10 +252,12 @@ static int can_optimize(unsigned long paddr)
 
/*
 * Do not optimize in the entry code due to the unstable
-* stack handling.
+* stack handling and registers setup.
 */
-   if ((paddr >= (unsigned long)__entry_text_start) &&
-   (paddr <  (unsigned long)__entry_text_end))
+   if (((paddr >= (unsigned long)__entry_text_start) &&
+(paddr <  (unsigned long)__entry_text_end)) ||
+   ((paddr >= (unsigned long)__irqentry_text_start) &&
+(paddr <  (unsigned long)__irqentry_text_end)))
return 0;
 
/* Check there is enough space for a relative jump. */



Re: MikeeUSA warning (Re: Yes you have standing to sue GRSecurity.)

2017-07-30 Thread nisus

First of all, give some proof of your accusation.

Second of all, prove the relevance of such.

Third of all: identity politics is off-topic in a discussion on 
copyright.


Is it not you, thus, who is trolling and attempting to derail the 
conversation?



On 2017-07-29 16:49, Adam Borowski wrote:
Note that this is quite clearly yet another of MikeeUSA's sockpuppets.  
And
you guys really don't want to be caught in another of his troll 
threads.


Yeah, GRsecurity is a problem, but don't let our dear Mikee milk it.


Re: [arch-general] Yes you have standing to sue GRSecurity.

2017-07-30 Thread nisus
Thank you. When earlier I brought up latches when I started 
brainstorming the defenses GRSecurity might raise, Bruce Perens quickly 
dismissed me as a "fool".


https://lists.debian.org/debian-user/2017/07/msg00830.html


OK, I apologize to all who were involved in this conversation. I will
block further emails from "aconcernedfossdev" and no longer encourage
him.

Bruce



(Later after a third party's inquiry, Bruce made this admission:)


The statement about Grsecurity still stands. Aconcernedfossdev was
wasting my time with naive argument and I don't have to suffer fools
gladly.

Thanks

Bruce


He also conflated my mentioning of the sometimes ongoing jailing of 
those found by the court to be in contempt for non-payment of civil 
debts to which the court feels the defendant has funds to pay and is 
simply holding out as me "conflating" criminal law with civil law 
and would not accept my answer as valid at all. I'm just a "fool".


I'm glad someone else recognizes the importance of recognizing the 
existence of potential procedural hurdles... and equitable defenses...


It angers me muchly that Bruce decided to libel me in this area simply 
because I started trying to anticipate the other side's moves once 
everyone understood that a cause of action existed.


On 2017-07-30 00:21, David C. Rankin wrote:

On 07/29/2017 07:53 AM, ni...@redchan.it wrote:
( NOTE: If you would like to read on how your copyright is being 
violated by

GRSecurity, Bruce Perens posted a good write-up on his web-page )
(
perens.com/blog/2017/06/28/warning-grsecurity-potential-contributory-infringement-risk-for-customers/
  )
( There was also a discussion on the linux section of slashdot, and on 
the
debian user mailing list, and on the dng devuan mailing list and on 
the

openwall mailing list and the fedora legal mailing list )


  Paul Allen's concerns on LKML that if the GPL rights are not 
asserted, then
any future, or additional violations, by grsecurity could raise the 
defenses
of waiver or latches against future actions based upon a failure to 
assert GPL

rights here (while dubious, they become additional hurdles that must be
responded to and overcome, regardless of their merit). Thread:
https://lkml.org/lkml/2017/7/29/128

  If you are a contributor, it makes sense to get in contact with 
others
similarly situated, and make sure you understand the competing issues, 
the

statute of limitations that apply, and the upside/downside to acting or
failing to act. No, I'm not looking for clients either, but will 
explore the

issue and contribute to the extent needed. I've followed the earlier
grsecurity threads on this list out of curiosity that something like 
this may

unfold.


Re: [PATCH 2/2] vfio/type1: Give hardware MSI regions precedence

2017-07-30 Thread Auger Eric
Hi Robin,
On 27/07/2017 16:54, Robin Murphy wrote:
> If the IOMMU driver advertises 'real' reserved regions for MSIs, but
> still includes the software-managed region as well, we are currently
> blind to the former and will configure the IOMMU domain to map MSIs into
> the latter, which is unlikely to work as expected.
> 
> Since it would take a ridiculous hardware topology for both regions to
> be valid (which would be rather difficult to support in general), we
> should be safe to assume that the presence of any hardware regions makes
> the software region irrelevant. However, the IOMMU driver might still
> advertise the software region by default, particularly if the hardware
> regions are filled in elsewhere by generic code, so it might not be fair
> for VFIO to be super-strict about not mixing them. To that end, make
> vfio_iommu_has_sw_msi() robust against the presence of both region types
> at once, so that we end up doing what is almost certainly right, rather
> than what is almost certainly wrong.
> 
> Signed-off-by: Robin Murphy 
Reviewed-by: Eric Auger 

Thanks

Eric
> ---
>  drivers/vfio/vfio_iommu_type1.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 2328be628f21..92155cce926d 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -1169,13 +1169,21 @@ static bool vfio_iommu_has_sw_msi(struct iommu_group 
> *group, phys_addr_t *base)
>   INIT_LIST_HEAD(&group_resv_regions);
>   iommu_get_group_resv_regions(group, &group_resv_regions);
>   list_for_each_entry(region, &group_resv_regions, list) {
> + /*
> +  * The presence of any 'real' MSI regions should take
> +  * precedence over the software-managed one if the
> +  * IOMMU driver happens to advertise both types.
> +  */
> + if (region->type == IOMMU_RESV_MSI) {
> + ret = false;
> + break;
> + }
> +
>   if (region->type == IOMMU_RESV_SW_MSI) {
>   *base = region->start;
>   ret = true;
> - goto out;
>   }
>   }
> -out:
>   list_for_each_entry_safe(region, next, &group_resv_regions, list)
>   kfree(region);
>   return ret;
> 


Re: [PATCH 1/2] vfio/type1: Cope with hardware MSI reserved regions

2017-07-30 Thread Auger Eric
Hi Robin,
On 27/07/2017 16:54, Robin Murphy wrote:
> For ARM-based systems with a GICv3 ITS to provide interrupt isolation,
> but hardware limitations which are worked around by having MSIs bypass
> SMMU translation (e.g. HiSilicon Hip06/Hip07), VFIO neglects to check
> for the IRQ_DOMAIN_FLAG_MSI_REMAP capability, (and thus erroneously
> demands unsafe_interrupts) if a software-managed MSI region is absent.
> 
> Fix this by always checking for isolation capability at both the IRQ
> domain and IOMMU domain levels, rather than predicating that on whether
> MSIs require an IOMMU mapping (which was always slightly tenuous logic).
> 
> Signed-off-by: Robin Murphy 
Reviewed-by: Eric Auger 

Thanks

Eric

> ---
>  drivers/vfio/vfio_iommu_type1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 8549cb111627..2328be628f21 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -1265,8 +1265,8 @@ static int vfio_iommu_type1_attach_group(void 
> *iommu_data,
>   INIT_LIST_HEAD(&domain->group_list);
>   list_add(&group->next, &domain->group_list);
>  
> - msi_remap = resv_msi ? irq_domain_check_msi_remap() :
> - iommu_capable(bus, IOMMU_CAP_INTR_REMAP);
> + msi_remap = irq_domain_check_msi_remap() ||
> + iommu_capable(bus, IOMMU_CAP_INTR_REMAP);
>  
>   if (!allow_unsafe_interrupts && !msi_remap) {
>   pr_warn("%s: No interrupt remapping support.  Use the module 
> param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this 
> platform\n",
> 


[tip:x86/mm] acpi, x86/mm: Remove encryption mask from ACPI page protection type

2017-07-30 Thread tip-bot for Tom Lendacky
Commit-ID:  57bd1905b228f2a14d7506b0302f69f425131e57
Gitweb: http://git.kernel.org/tip/57bd1905b228f2a14d7506b0302f69f425131e57
Author: Tom Lendacky 
AuthorDate: Fri, 28 Jul 2017 11:01:17 -0500
Committer:  Ingo Molnar 
CommitDate: Sun, 30 Jul 2017 12:09:12 +0200

acpi, x86/mm: Remove encryption mask from ACPI page protection type

The arch_apei_get_mem_attributes() function is used to set the page
protection type for ACPI physical addresses. When SME is active, the
associated protection type cannot have the encryption mask set since the
ACPI tables live in un-encrypted memory - the kernel will see corrupted
data.

To fix this, create a new protection type, PAGE_KERNEL_NOENC, that is a
'no encryption' version of PAGE_KERNEL, and return that from
arch_apei_get_mem_attributes().

Signed-off-by: Tom Lendacky 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brijesh Singh 
Cc: Dave Young 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/e1cb9395b2f061cd96f1e59c3cbbe5ff5d4ec26e.1501186516.git.thomas.lenda...@amd.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/acpi.h  | 11 ++-
 arch/x86/include/asm/pgtable_types.h |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 562286f..72d867f 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -160,12 +160,13 @@ static inline pgprot_t 
arch_apei_get_mem_attribute(phys_addr_t addr)
 * you call efi_mem_attributes() during boot and at runtime,
 * you could theoretically see different attributes.
 *
-* Since we are yet to see any x86 platforms that require
-* anything other than PAGE_KERNEL (some arm64 platforms
-* require the equivalent of PAGE_KERNEL_NOCACHE), return that
-* until we know differently.
+* We are yet to see any x86 platforms that require anything
+* other than PAGE_KERNEL (some ARM64 platforms require the
+* equivalent of PAGE_KERNEL_NOCACHE). Additionally, if SME
+* is active, the ACPI information will not be encrypted,
+* so return PAGE_KERNEL_NOENC until we know differently.
 */
-return PAGE_KERNEL;
+   return PAGE_KERNEL_NOENC;
 }
 #endif
 
diff --git a/arch/x86/include/asm/pgtable_types.h 
b/arch/x86/include/asm/pgtable_types.h
index 6c55973..399261c 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -211,6 +211,7 @@ enum page_cache_mode {
 #define __PAGE_KERNEL_NOENC_WP (__PAGE_KERNEL_WP)
 
 #define PAGE_KERNEL__pgprot(__PAGE_KERNEL | _PAGE_ENC)
+#define PAGE_KERNEL_NOENC  __pgprot(__PAGE_KERNEL)
 #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO | _PAGE_ENC)
 #define PAGE_KERNEL_EXEC   __pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC)
 #define PAGE_KERNEL_EXEC_NOENC __pgprot(__PAGE_KERNEL_EXEC)


[tip:x86/mm] x86/mm, kexec: Fix memory corruption with SME on successive kexecs

2017-07-30 Thread tip-bot for Tom Lendacky
Commit-ID:  4e237903f95db585b976e7311de2bfdaaf0f6e31
Gitweb: http://git.kernel.org/tip/4e237903f95db585b976e7311de2bfdaaf0f6e31
Author: Tom Lendacky 
AuthorDate: Fri, 28 Jul 2017 11:01:16 -0500
Committer:  Ingo Molnar 
CommitDate: Sun, 30 Jul 2017 12:09:12 +0200

x86/mm, kexec: Fix memory corruption with SME on successive kexecs

After issuing successive kexecs it was found that the SHA hash failed
verification when booting the kexec'd kernel.  When SME is enabled, the
change from using pages that were marked encrypted to now being marked as
not encrypted (through new identify mapped page tables) results in memory
corruption if there are any cache entries for the previously encrypted
pages. This is because separate cache entries can exist for the same
physical location but tagged both with and without the encryption bit.

To prevent this, issue a wbinvd if SME is active before copying the pages
from the source location to the destination location to clear any possible
cache entry conflicts.

Signed-off-by: Tom Lendacky 
Cc: 
Cc: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brijesh Singh 
Cc: Dave Young 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: 
http://lkml.kernel.org/r/e7fb8610af3a93e8f8ae6f214cd9249adc0df2b4.1501186516.git.thomas.lenda...@amd.com
Signed-off-by: Ingo Molnar 
---
 arch/x86/include/asm/kexec.h |  3 ++-
 arch/x86/kernel/machine_kexec_64.c   |  3 ++-
 arch/x86/kernel/relocate_kernel_64.S | 14 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
index e8183ac..942c1f4 100644
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -147,7 +147,8 @@ unsigned long
 relocate_kernel(unsigned long indirection_page,
unsigned long page_list,
unsigned long start_address,
-   unsigned int preserve_context);
+   unsigned int preserve_context,
+   unsigned int sme_active);
 #endif
 
 #define ARCH_HAS_KIMAGE_ARCH
diff --git a/arch/x86/kernel/machine_kexec_64.c 
b/arch/x86/kernel/machine_kexec_64.c
index 9cf8daa..1f790cf 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -335,7 +335,8 @@ void machine_kexec(struct kimage *image)
image->start = relocate_kernel((unsigned long)image->head,
   (unsigned long)page_list,
   image->start,
-  image->preserve_context);
+  image->preserve_context,
+  sme_active());
 
 #ifdef CONFIG_KEXEC_JUMP
if (image->preserve_context)
diff --git a/arch/x86/kernel/relocate_kernel_64.S 
b/arch/x86/kernel/relocate_kernel_64.S
index 98111b3..307d3ba 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -47,6 +47,7 @@ relocate_kernel:
 * %rsi page_list
 * %rdx start address
 * %rcx preserve_context
+* %r8  sme_active
 */
 
/* Save the CPU context, used for jumping back */
@@ -71,6 +72,9 @@ relocate_kernel:
pushq $0
popfq
 
+   /* Save SME active flag */
+   movq%r8, %r12
+
/*
 * get physical address of control page now
 * this is impossible after page table switch
@@ -132,6 +136,16 @@ identity_mapped:
/* Flush the TLB (needed?) */
movq%r9, %cr3
 
+   /*
+* If SME is active, there could be old encrypted cache line
+* entries that will conflict with the now unencrypted memory
+* used by kexec. Flush the caches before copying the kernel.
+*/
+   testq   %r12, %r12
+   jz 1f
+   wbinvd
+1:
+
movq%rcx, %r11
callswap_pages
 


Re: [RFC PATCH v12 3/4] Linux Random Number Generator

2017-07-30 Thread Pavel Machek
Hi!

On Tue 2017-07-18 21:51:33, Theodore Ts'o wrote:
> On Tue, Jul 18, 2017 at 09:00:10PM -0400, Sandy Harris wrote:
> > The only really good solution I know of is to find a way to provide a
> > chunk of randomness early in the boot process. John Denker has a good
> > discussion of doing this by modifying the kernel image & Ted talks of
> > doing it via the boot loader. Neither looks remarkably easy. Other
> > approaches like making the kernel read a seed file or passing a
> > parameter on the kernel command line have been suggested but, if I
> > recall right, rejected.
> 
> It's actually not that _hard_ to modify the boot loader.  It's not
> finicky work like, say, adding support for metadata checksums or xattr
> deduplication to ext4.  It's actually mostly plumbing.  It's just that
> we haven't found a lot of people willing to do it as paid work, and
> the hobbyists haven't been interested.

Modifying the boot loader sources is not hard, right.

Deploying the modified boot loader is another story; these are
bootloaders -- they normally don't need updating, so they are often
not easy to update, or maybe updating them is risky.

Anyway, if you want to pay for some bootloader modifications... I'm
working for a company that can help :-). (Sometimes I use
pa...@denx.de address.)

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH] mfd: lp87565: Convert to use devm_mfd_add_devices

2017-07-30 Thread Axel Lin
This fixes missing mfd_remove_devices() call when unload the module.

Signed-off-by: Axel Lin 
---
 drivers/mfd/lp87565.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/lp87565.c b/drivers/mfd/lp87565.c
index 340ad0c..32d2a07 100644
--- a/drivers/mfd/lp87565.c
+++ b/drivers/mfd/lp87565.c
@@ -73,10 +73,9 @@ static int lp87565_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, lp87565);
 
-   ret = mfd_add_devices(lp87565->dev, PLATFORM_DEVID_AUTO, lp87565_cells,
- ARRAY_SIZE(lp87565_cells), NULL, 0, NULL);
-
-   return ret;
+   return devm_mfd_add_devices(lp87565->dev, PLATFORM_DEVID_AUTO,
+   lp87565_cells, ARRAY_SIZE(lp87565_cells),
+   NULL, 0, NULL);
 }
 
 static const struct i2c_device_id lp87565_id_table[] = {
-- 
2.9.3



Re: [PATCH] b43legacy: Fix a sleep-in-atomic bug in b43legacy_attr_interfmode_store

2017-07-30 Thread Michael Büsch
On Fri, 02 Jun 2017 09:18:14 +0800
Jia-Ju Bai  wrote:

> On 06/02/2017 12:11 AM, Jonathan Corbet wrote:
> > On Thu, 01 Jun 2017 09:05:07 +0800
> > Jia-Ju Bai  wrote:
> >  
> >> I admit my patches are not well tested, and they may not well fix the bugs.
> >> I am looking forward to opinions and suggestions :)  
> > May I politely suggest that sending out untested locking changes is a
> > dangerous thing to do?  You really should not be changing the locking in a
> > piece of kernel code without understanding very well what the lock is
> > protecting and being able to say why your changes are safe.  Without that,
> > the risk of introducing subtle bugs is very high.
> >
> > It looks like you have written a useful tool that could help us to make
> > the kernel more robust.  If you are interested in my suggestion, I would
> > recommend that you post the sleep-in-atomic scenarios that you are
> > finding, but refrain from "fixing" them in any case where you cannot offer
> > a strong explanation of why your fix is correct.
> >
> > Thanks for working to find bugs in the kernel!
> >
> > jon  
> Hi,
> 
> Thanks for your good and helpful advice. I am sorry for my improper patches.
> I will only report bugs instead of sending improper patches when I have 
> no good solution of fixing the bugs.


Is somebody still working on these fixes?
I think I found my old b43-legacy based 4306, so that I will
be able to get these patches into properly tested shape.

-- 
Michael


pgpSRaLzxvqv8.pgp
Description: OpenPGP digital signature


Re: [PATCH] kvm: x86: fix a race condition result to lost INIT

2017-07-30 Thread Wanpeng Li
2017-07-30 18:42 GMT+08:00  :
>> 2017-07-31 0:24 GMT+08:00 Peng Hao :
>
>> > when SMP VM start, AP may lost INIT because of receiving INIT between
>> > kvm_vcpu_ioctl_x86_get/set_vcpu_events.
>> >
>> >vcpu 0 vcpu 1
>> >kvm_vcpu_ioctl_x86_get_vcpu_events
>> >events->smi.latched_init=0
>> >  send INIT to vcpu1
>> >set vcpu1's pending_events
>> >kvm_vcpu_ioctl_x86_set_vcpu_events
>> > events->smi.latched_init == 0
>> >   clear INIT in pending_events
>> > I don't think it need set/clear kernel state according to userspace's
>> > info.
>> >
>> > Signed-off-by: Peng Hao 
>> > ---
>> >  arch/x86/kvm/x86.c | 6 --
>> >  1 file changed, 6 deletions(-)
>> >
>> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> > index 6c7266f..393a7b7 100644
>> > --- a/arch/x86/kvm/x86.c
>> > +++ b/arch/x86/kvm/x86.c
>> > @@ -3157,12 +3157,6 @@ static int
>> > kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
>> > vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
>> > else
>> > vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK;
>> > -   if (lapic_in_kernel(vcpu)) {
>> > -   if (events->smi.latched_init)
>> > -   set_bit(KVM_APIC_INIT,
>> > &vcpu->arch.apic->pending_events);
>
>> This is not correct, you will lose the INIT after live migration. I
>> just send out another patch to fix it. Thanks for the report.
>
> yes, you're right. I should modify on qemu not kernel.

There is a patch here to fix it in kvm, https://lkml.org/lkml/2017/7/30/72

Regards,
Wanpeng Li

>
>> > -   else
>> > -   clear_bit(KVM_APIC_INIT,
>> > &vcpu->arch.apic->pending_events);
>> > -   }
>> > }
>
>
>


[PATCH] arm64: dts: realtek: Clean up RTD1295 UART reg property

2017-07-30 Thread Andreas Färber
The downstream RTD1195 and apparently RTD1295 trees have a modified 8250
serial driver that acknowledges its interrupts using the second reg area,
which is an irq mux.

Drop these unused second reg entries for the UART nodes.

Fixes: 72a7786c0a0d ("ARM64: dts: Add Realtek RTD1295 and Zidoo X9S")
Signed-off-by: Andreas Färber 
---
 arch/arm64/boot/dts/realtek/rtd1295.dtsi | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/realtek/rtd1295.dtsi 
b/arch/arm64/boot/dts/realtek/rtd1295.dtsi
index d8f84666c8ce..43da91fce2b1 100644
--- a/arch/arm64/boot/dts/realtek/rtd1295.dtsi
+++ b/arch/arm64/boot/dts/realtek/rtd1295.dtsi
@@ -89,8 +89,7 @@
 
uart0: serial@98007800 {
compatible = "snps,dw-apb-uart";
-   reg = <0x98007800 0x400>,
- <0x98007000 0x100>;
+   reg = <0x98007800 0x400>;
reg-shift = <2>;
reg-io-width = <4>;
clock-frequency = <2700>;
@@ -99,8 +98,7 @@
 
uart1: serial@9801b200 {
compatible = "snps,dw-apb-uart";
-   reg = <0x9801b200 0x100>,
- <0x9801b00c 0x100>;
+   reg = <0x9801b200 0x100>;
reg-shift = <2>;
reg-io-width = <4>;
clock-frequency = <43200>;
@@ -109,8 +107,7 @@
 
uart2: serial@9801b400 {
compatible = "snps,dw-apb-uart";
-   reg = <0x9801b400 0x100>,
- <0x9801b00c 0x100>;
+   reg = <0x9801b400 0x100>;
reg-shift = <2>;
reg-io-width = <4>;
clock-frequency = <43200>;
-- 
2.12.3



[PATCH 1/3] sound: ASoC: tegra: Remove SoC-specific Kconfig depends and selects

2017-07-30 Thread Paul Kocialkowski
This removes the SoC-specific dependencies on the platform drivers,
as well as SoC-specific selections of platform drivers for the
machine drivers. The rationale behind this change is that the
dependencies are not actual build dependencies but run-time ones.

The previously listed SoCs were also incomplete: for instance, tegra124
uses the tegra30 platform drivers, which could not be built without
ARCH_TEGRA_3x_SOC set.

Descriptions of the tristates are also added to allow these options
to be set via defconfig/menuconfig.

Signed-off-by: Paul Kocialkowski 
---
 sound/soc/tegra/Kconfig | 42 ++
 1 file changed, 14 insertions(+), 28 deletions(-)

diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index efbe8d4c019e..6875fc39a575 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -9,8 +9,8 @@ config SND_SOC_TEGRA
  Say Y or M here if you want support for SoC audio on Tegra.
 
 config SND_SOC_TEGRA20_AC97
-   tristate
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC
+   tristate "Tegra20 AC97 interface"
+   depends on SND_SOC_TEGRA
select SND_SOC_AC97_BUS
select SND_SOC_TEGRA20_DAS
help
@@ -19,16 +19,16 @@ config SND_SOC_TEGRA20_AC97
  machine drivers to support below.
 
 config SND_SOC_TEGRA20_DAS
-   tristate
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC
+   tristate "Tegra20 DAS module"
+   depends on SND_SOC_TEGRA
help
  Say Y or M if you want to add support for the Tegra20 DAS module.
  You will also need to select the individual machine drivers to
  support below.
 
 config SND_SOC_TEGRA20_I2S
-   tristate
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC
+   tristate "Tegra20 I2S interface"
+   depends on SND_SOC_TEGRA
select SND_SOC_TEGRA20_DAS
help
  Say Y or M if you want to add support for codecs attached to the
@@ -36,8 +36,8 @@ config SND_SOC_TEGRA20_I2S
  machine drivers to support below.
 
 config SND_SOC_TEGRA20_SPDIF
-   tristate
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC
+   tristate "Tegra20 SPDIF interface"
+   depends on SND_SOC_TEGRA
default m
help
  Say Y or M if you want to add support for the Tegra20 SPDIF interface.
@@ -45,16 +45,16 @@ config SND_SOC_TEGRA20_SPDIF
  below.
 
 config SND_SOC_TEGRA30_AHUB
-   tristate
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_3x_SOC
+   tristate "Tegra30 AHUB module"
+   depends on SND_SOC_TEGRA
help
- Say Y or M if you want to add support for the Tegra20 AHUB module.
+ Say Y or M if you want to add support for the Tegra30 AHUB module.
  You will also need to select the individual machine drivers to
  support below.
 
 config SND_SOC_TEGRA30_I2S
-   tristate
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_3x_SOC
+   tristate "Tegra30 I2S interface"
+   depends on SND_SOC_TEGRA
select SND_SOC_TEGRA30_AHUB
help
  Say Y or M if you want to add support for codecs attached to the
@@ -64,8 +64,6 @@ config SND_SOC_TEGRA30_I2S
 config SND_SOC_TEGRA_RT5640
tristate "SoC Audio support for Tegra boards using an RT5640 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
-   select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC
-   select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC
select SND_SOC_RT5640
help
  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -74,8 +72,6 @@ config SND_SOC_TEGRA_RT5640
 config SND_SOC_TEGRA_WM8753
tristate "SoC Audio support for Tegra boards using a WM8753 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
-   select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC
-   select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC
select SND_SOC_WM8753
help
  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -84,8 +80,6 @@ config SND_SOC_TEGRA_WM8753
 config SND_SOC_TEGRA_WM8903
tristate "SoC Audio support for Tegra boards using a WM8903 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
-   select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC
-   select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC
select SND_SOC_WM8903
help
  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -94,7 +88,7 @@ config SND_SOC_TEGRA_WM8903
 
 config SND_SOC_TEGRA_WM9712
tristate "SoC Audio support for Tegra boards using a WM9712 codec"
-   depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC && GPIOLIB
+   depends on SND_SOC_TEGRA && GPIOLIB
select SND_SOC_TEGRA20_AC97
select SND_SOC_WM9712
help
@@ -104,7 +98,6 @@ config SND_SOC_TEGRA_WM9712
 config SND_SOC_TEGRA_TRIMSLICE
tristate "SoC Audio support for TrimSlice board"
depends on SND_SOC_TEGRA && I2C
-   select SND_SOC_TEGRA20_I2S 

[PATCH 3/3] ARM: configs: Add Tegra I2S interfaces to multi_v7_defconfig

2017-07-30 Thread Paul Kocialkowski
This selects both the Tegra20 and Tegra30 I2S interfaces (that were
previously auto-selected by Kconfig but are not anymore) to
multi_v7_defconfig, as modules.

Signed-off-by: Paul Kocialkowski 
---
 arch/arm/configs/multi_v7_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index 4d19c1b4b8e7..626cecdada61 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -653,6 +653,8 @@ CONFIG_SND_SOC_RCAR=m
 CONFIG_SND_SOC_RSRC_CARD=m
 CONFIG_SND_SUN4I_CODEC=m
 CONFIG_SND_SOC_TEGRA=m
+CONFIG_SND_SOC_TEGRA20_I2S=m
+CONFIG_SND_SOC_TEGRA30_I2S=m
 CONFIG_SND_SOC_TEGRA_RT5640=m
 CONFIG_SND_SOC_TEGRA_WM8753=m
 CONFIG_SND_SOC_TEGRA_WM8903=m
-- 
2.13.3



[PATCH 2/3] ARM: configs: Add Tegra I2S interfaces to tegra_defconfig

2017-07-30 Thread Paul Kocialkowski
This selects both the Tegra20 and Tegra30 I2S interfaces (that were
previously auto-selected by Kconfig but are not anymore) to
tegra_defconfig, as built-ins.

Signed-off-by: Paul Kocialkowski 
---
 arch/arm/configs/tegra_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index f0efc854b5a2..fe1275aa067e 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -202,6 +202,8 @@ CONFIG_SND_HDA_CODEC_HDMI=y
 # CONFIG_SND_USB is not set
 CONFIG_SND_SOC=y
 CONFIG_SND_SOC_TEGRA=y
+CONFIG_SND_SOC_TEGRA20_I2S=y
+CONFIG_SND_SOC_TEGRA30_I2S=y
 CONFIG_SND_SOC_TEGRA_RT5640=y
 CONFIG_SND_SOC_TEGRA_WM8753=y
 CONFIG_SND_SOC_TEGRA_WM8903=y
-- 
2.13.3



Re: [PATCH] kvm: x86: fix a race condition result to lost INIT

2017-07-30 Thread Wanpeng Li
2017-07-30 19:33 GMT+08:00  :
>
>
>
>
>>2017-07-30 18:42 GMT+08:00  :
>
 2017-07-31 0:24 GMT+08:00 Peng Hao :
>>>
 > when SMP VM start, AP may lost INIT because of receiving INIT between
 > kvm_vcpu_ioctl_x86_get/set_vcpu_events.
 >
 >vcpu 0 vcpu 1
 >kvm_vcpu_ioctl_x86_get_vcpu_events
 >events->smi.latched_init=0
 >  send INIT to vcpu1
 >set vcpu1's pending_events
 >kvm_vcpu_ioctl_x86_set_vcpu_events
 > events->smi.latched_init == 0
 >   clear INIT in pending_events
 > I don't think it need set/clear kernel state according to userspace's
 > info.
 >
 > Signed-off-by: Peng Hao 
 > ---
 >  arch/x86/kvm/x86.c | 6 --
 >  1 file changed, 6 deletions(-)
 >
 > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
 > index 6c7266f..393a7b7 100644
 > --- a/arch/x86/kvm/x86.c
 > +++ b/arch/x86/kvm/x86.c
 > @@ -3157,12 +3157,6 @@ static int
 > kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
 > vcpu->arch.hflags |= HF_SMM_INSIDE_NMI_MASK;
 > else
 > vcpu->arch.hflags &= ~HF_SMM_INSIDE_NMI_MASK;
 > -   if (lapic_in_kernel(vcpu)) {
 > -   if (events->smi.latched_init)
 > -   set_bit(KVM_APIC_INIT,
 > &vcpu->arch.apic->pending_events);
>>>
 This is not correct, you will lose the INIT after live migration. I
 just send out another patch to fix it. Thanks for the report.
>>>
>>> yes, you're right. I should modify on qemu not kernel.
>
>>There is a patch here to fix it in kvm, https://lkml.org/lkml/2017/7/30/72
>
>>>
>
> I was affected by sipi, kernel never report  valid sipi to user space,

How you afftected by SIPI? In addition, you reported the lost of INIT.
Is it observed by your workload or by code review?

Regards,
Wanpeng Li

>
> we don't care whether sipi is lost  after migration. Why?
>
 > -   else
 > -   clear_bit(KVM_APIC_INIT,
 > &vcpu->arch.apic->pending_events);
 > -   }
 > }
>
>
>


Re: [RFC PATCH v2 10/38] KVM: arm/arm64: Add a framework to prepare virtual EL2 execution

2017-07-30 Thread Christoffer Dall
On Tue, Jul 18, 2017 at 11:58:36AM -0500, Jintack Lim wrote:
> From: Christoffer Dall 
> 
> Add functions setting up and restoring the guest's context on each entry
> and exit. These functions will come in handy when we want to use
> different context for normal EL0/EL1 and virtual EL2 execution.
> 
> No functional change yet.
> 
> Signed-off-by: Christoffer Dall 
> Signed-off-by: Jintack Lim 
> ---
>  arch/arm/include/asm/kvm_emulate.h   |   4 ++
>  arch/arm64/include/asm/kvm_emulate.h |   4 ++
>  arch/arm64/kvm/Makefile  |   2 +-
>  arch/arm64/kvm/context.c |  54 
>  arch/arm64/kvm/hyp/sysreg-sr.c   | 117 
> +++
>  virt/kvm/arm/arm.c   |  14 +
>  6 files changed, 140 insertions(+), 55 deletions(-)
>  create mode 100644 arch/arm64/kvm/context.c
> 
> diff --git a/arch/arm/include/asm/kvm_emulate.h 
> b/arch/arm/include/asm/kvm_emulate.h
> index 399cd75e..0a03b7d 100644
> --- a/arch/arm/include/asm/kvm_emulate.h
> +++ b/arch/arm/include/asm/kvm_emulate.h
> @@ -47,6 +47,10 @@ static inline void vcpu_set_reg(struct kvm_vcpu *vcpu, u8 
> reg_num,
>  void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
>  void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
>  
> +static inline void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu) { };
> +static inline void kvm_arm_restore_shadow_state(struct kvm_vcpu *vcpu) { };
> +static inline void kvm_arm_init_cpu_context(kvm_cpu_context_t *cpu_ctxt) { };
> +
>  static inline bool kvm_condition_valid(const struct kvm_vcpu *vcpu)
>  {
>   return kvm_condition_valid32(vcpu);
> diff --git a/arch/arm64/include/asm/kvm_emulate.h 
> b/arch/arm64/include/asm/kvm_emulate.h
> index 5d6f3d0..14c4ce9 100644
> --- a/arch/arm64/include/asm/kvm_emulate.h
> +++ b/arch/arm64/include/asm/kvm_emulate.h
> @@ -42,6 +42,10 @@
>  void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
>  void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
>  
> +void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu);
> +void kvm_arm_restore_shadow_state(struct kvm_vcpu *vcpu);
> +void kvm_arm_init_cpu_context(kvm_cpu_context_t *cpu_ctxt);
> +
>  static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
>  {
>   vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS;
> diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile
> index f513047..5762337 100644
> --- a/arch/arm64/kvm/Makefile
> +++ b/arch/arm64/kvm/Makefile
> @@ -15,7 +15,7 @@ kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o 
> $(KVM)/coalesced_mmio.o $(KVM)/e
>  kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arm.o $(KVM)/arm/mmu.o 
> $(KVM)/arm/mmio.o
>  kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/psci.o $(KVM)/arm/perf.o
>  
> -kvm-$(CONFIG_KVM_ARM_HOST) += inject_fault.o regmap.o
> +kvm-$(CONFIG_KVM_ARM_HOST) += inject_fault.o regmap.o context.o
>  kvm-$(CONFIG_KVM_ARM_HOST) += hyp.o hyp-init.o handle_exit.o
>  kvm-$(CONFIG_KVM_ARM_HOST) += guest.o debug.o reset.o sys_regs.o 
> sys_regs_generic_v8.o
>  kvm-$(CONFIG_KVM_ARM_HOST) += vgic-sys-reg-v3.o
> diff --git a/arch/arm64/kvm/context.c b/arch/arm64/kvm/context.c
> new file mode 100644
> index 000..bc43e66
> --- /dev/null
> +++ b/arch/arm64/kvm/context.c
> @@ -0,0 +1,54 @@
> +/*
> + * Copyright (C) 2016 - Linaro Ltd.
> + * Author: Christoffer Dall 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see .
> + */
> +
> +#include 
> +#include 
> +
> +/**
> + * kvm_arm_setup_shadow_state -- prepare shadow state based on emulated mode
> + * @vcpu: The VCPU pointer
> + */
> +void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
> +{
> + struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt;
> +
> + ctxt->hw_pstate = *vcpu_cpsr(vcpu);
> + ctxt->hw_sys_regs = ctxt->sys_regs;
> + ctxt->hw_sp_el1 = ctxt->gp_regs.sp_el1;
> + ctxt->hw_elr_el1 = ctxt->gp_regs.elr_el1;
> + ctxt->hw_spsr_el1 = ctxt->gp_regs.spsr[KVM_SPSR_EL1];
> +}
> +
> +/**
> + * kvm_arm_restore_shadow_state -- write back shadow state from guest
> + * @vcpu: The VCPU pointer
> + */
> +void kvm_arm_restore_shadow_state(struct kvm_vcpu *vcpu)
> +{
> + struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt;
> +
> + *vcpu_cpsr(vcpu) = ctxt->hw_pstate;
> + ctxt->gp_regs.sp_el1 = ctxt->hw_sp_el1;
> + ctxt->gp_regs.elr_el1 = ctxt->hw_elr_el1;
> + ctxt->gp_regs.spsr[KVM_SPSR_EL1] = ctxt->hw_spsr_el1;
> +}
> +
> +void kvm_arm_init_cpu_con

Re: [RFC 01/12] clk: qcom: support for register offsets from rcg2 clock node

2017-07-30 Thread Abhishek Sahu

On 2017-07-28 23:25, Stephen Boyd wrote:

On 07/28, Abhishek Sahu wrote:

On 2017-07-28 00:14, Stephen Boyd wrote:
>
>It looks like the two UBI clks that messed this up don't have an MN
>counter, so instead of doing this maddness, just add a flag like

 I have given example for one of the RCG. IPQ8074 have more clocks for
 which the offsets are not continuous and some of the clocks have
 mn counter also (NSS Crypto and PCIE AUX)

 GCC_NSS_UBI0_CMD_RCGR 0x1868100
 GCC_NSS_UBI0_CFG_RCGR 0x1868108
 GCC_NSS_UBI1_CMD_RCGR 0x1868120
 GCC_NSS_UBI1_CFG_RCGR 0x1868128

 GCC_NSS_CRYPTO_CMD_RCGR 0x1868140
 GCC_NSS_CRYPTO_CFG_RCGR 0x1868148
 GCC_NSS_CRYPTO_M 0x186814C
 GCC_NSS_CRYPTO_N 0x1868150
 GCC_NSS_CRYPTO_D 0x1868154

 GCC_PCIE0_AUX_CMD_RCGR 0x1875020
 GCC_PCIE0_AUX_CFG_RCGR 0x1875028
 GCC_PCIE0_AUX_M 0x187502C
 GCC_PCIE0_AUX_N 0x1875030
 GCC_PCIE0_AUX_D 0x1875034

 GCC_PCIE0_AXI_CMD_RCGR 0x1875050
 GCC_PCIE0_AXI_CFG_RCGR 0x1875058

 Similarly for PCIE1 also.


Wow. This is awful. Please make sure this never happens again. I
will go yell at someone as well.



 Yes. We also yelled badly at HW team for this and raised
 the HW bug before tapeout itself but they didn't fix by
 saying that this change will be risky and can have side
 effects.



>m_is_cfg and then make a rcg2_crmd() function that checks this flag and
>returns cmd_rcg + CFG_REG or cmd_rgcr + M_REG depending on the flag. We

 The original idea was to make this generic so in future for all the
cases
 it will work. If we can make function and since some clocks have MN
 counter, so could we make function for CMD reg itself instead of
CFG reg.


I understand the idea. We don't want it to happen again in the
future though, so let's not make it easy to support in the future
with some register map thing. Hardware people should follow the
rules and stop messing with the register layout!


 For this, pass cmd_rcgr as + 4 from GCC driver and when this flag
is set
 then do minus 4 for all CMD_REG



Ok. That's a good solution.

Just to be clear, let's have a flag like 'cmd_reg_is_wrong' (feel
free to think of a better name) and then have the places where we
access CMD_REG subtract that by 4, again with some special
macro/function, and then have the IPQ gcc driver specify the
cmd_rcgr as the real register + 4. Then the other hardcoded
offsets can all be the same and the few places that we access
CMD_REG we can subtract 4 to get the true location. And put all
that under an ifdef in some macro, so that we don't care about
this problem at all if we're not compiling this broken hardware
driver.


 Sure. Same plan here and I will do the same.


  1   2   3   4   >