A few more filesystem encryption questions
Hello, A few more questions about the new filesystem encryption code: I found that a process without access to the master encryption key can read a file's full decrypted contents, provided that the file was opened recently by a process with access to the key. This is true even if the privileged process merely opened and closed the file, without reading any bytes. A similar story applies to filenames; a 'ls' by a process able to decrypt the names reveals them to all users/processes. Essentially, it seems that despite the use of the kernel keyrings mechanism where different users/processes can have different keys, this doesn't fully carry over into filesystem encryption. Is this a known and understood limitation of the design? The design document states that an encryption policy can be changed "if the directory is empty or the file is 0 bytes in length". However, the code doesn't allow an existing encryption policy to be changed. Which behavior was intended? I had brought up the question of the endianness of the XTS tweak value. I also realized that since the page index is used, the XTS tweak will be dependent on PAGE_SIZE. So the current behavior is that an encrypted filesystem can only be read on a device with the same endianness _and_ PAGE_SIZE. Is is the case that due to the early Android users, it is too late to start using the byte offset instead of the PAGE_SIZE? What about if the XTS tweak was fixed as the number of 4096-byte blocks from the start of the file as a le64 --- is that what the existing users are expected to be doing in practice? Are there any architectures with PAGE_SIZE < 4096 for which that value wouldn't work? Eric
A few more filesystem encryption questions
Hello, A few more questions about the new filesystem encryption code: I found that a process without access to the master encryption key can read a file's full decrypted contents, provided that the file was opened recently by a process with access to the key. This is true even if the privileged process merely opened and closed the file, without reading any bytes. A similar story applies to filenames; a 'ls' by a process able to decrypt the names reveals them to all users/processes. Essentially, it seems that despite the use of the kernel keyrings mechanism where different users/processes can have different keys, this doesn't fully carry over into filesystem encryption. Is this a known and understood limitation of the design? The design document states that an encryption policy can be changed "if the directory is empty or the file is 0 bytes in length". However, the code doesn't allow an existing encryption policy to be changed. Which behavior was intended? I had brought up the question of the endianness of the XTS tweak value. I also realized that since the page index is used, the XTS tweak will be dependent on PAGE_SIZE. So the current behavior is that an encrypted filesystem can only be read on a device with the same endianness _and_ PAGE_SIZE. Is is the case that due to the early Android users, it is too late to start using the byte offset instead of the PAGE_SIZE? What about if the XTS tweak was fixed as the number of 4096-byte blocks from the start of the file as a le64 --- is that what the existing users are expected to be doing in practice? Are there any architectures with PAGE_SIZE < 4096 for which that value wouldn't work? Eric
Re: [PATCH 0/3] mm/mmap.c: don't unmap the overlapping VMA(s)
On Sat, Apr 2, 2016 at 10:17 PM, Piotr Kwapulinskiwrote: > Currently the mmap(MAP_FIXED) discards the overlapping part of the > existing VMA(s). > Introduce the new MAP_DONTUNMAP flag which forces the mmap to fail > with ENOMEM whenever the overlapping occurs and MAP_FIXED is set. > No existing mapping(s) is discarded. How userspace is supposed to use this and handle failure? For now you can get the same behavior in couple syscalls: mmap without MAP_FIXED if resulting address differs unmmap and handle error. Twice slower but this is error-path so you anyway have to some extra actions. > The implementation tests the MAP_DONTUNMAP flag right before unmapping > the VMA. The tile arch is the dependency of mmap_flags. > > I did the isolated tests and also tested it with Gentoo full > installation. > > Signed-off-by: Piotr Kwapulinski > --- > arch/tile/mm/elf.c | 1 + > include/linux/mm.h | 3 ++- > include/uapi/asm-generic/mman-common.h | 1 + > mm/mmap.c | 10 +++--- > 4 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/arch/tile/mm/elf.c b/arch/tile/mm/elf.c > index 6225cc9..dae4b33 100644 > --- a/arch/tile/mm/elf.c > +++ b/arch/tile/mm/elf.c > @@ -142,6 +142,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, > if (!retval) { > unsigned long addr = MEM_USER_INTRPT; > addr = mmap_region(NULL, addr, INTRPT_SIZE, > + MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE, >VM_READ|VM_EXEC| >VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 0); > if (addr > (unsigned long) -PAGE_SIZE) > diff --git a/include/linux/mm.h b/include/linux/mm.h > index ed6407d..31dcdfb 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2048,7 +2048,8 @@ extern int install_special_mapping(struct mm_struct *mm, > extern unsigned long get_unmapped_area(struct file *, unsigned long, > unsigned long, unsigned long, unsigned long); > > extern unsigned long mmap_region(struct file *file, unsigned long addr, > - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff); > + unsigned long len, unsigned long mmap_flags, > + vm_flags_t vm_flags, unsigned long pgoff); > extern unsigned long do_mmap(struct file *file, unsigned long addr, > unsigned long len, unsigned long prot, unsigned long flags, > vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate); > diff --git a/include/uapi/asm-generic/mman-common.h > b/include/uapi/asm-generic/mman-common.h > index 5827438..3655be3 100644 > --- a/include/uapi/asm-generic/mman-common.h > +++ b/include/uapi/asm-generic/mman-common.h > @@ -19,6 +19,7 @@ > #define MAP_TYPE 0x0f/* Mask for type of mapping */ > #define MAP_FIXED 0x10/* Interpret addr exactly */ > #define MAP_ANONYMOUS 0x20/* don't use a file */ > +#define MAP_DONTUNMAP 0x40/* don't unmap overlapping VMA */ > #ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED > # define MAP_UNINITIALIZED 0x400 /* For anonymous mmap, memory could > be uninitialized */ > #else > diff --git a/mm/mmap.c b/mm/mmap.c > index bd2e1a53..ab429c3 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -1286,7 +1286,7 @@ unsigned long do_mmap(struct file *file, unsigned long > addr, > vm_flags |= VM_NORESERVE; > } > > - addr = mmap_region(file, addr, len, vm_flags, pgoff); > + addr = mmap_region(file, addr, len, flags, vm_flags, pgoff); > if (!IS_ERR_VALUE(addr) && > ((vm_flags & VM_LOCKED) || > (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE)) > @@ -1422,7 +1422,8 @@ static inline int accountable_mapping(struct file > *file, vm_flags_t vm_flags) > } > > unsigned long mmap_region(struct file *file, unsigned long addr, > - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff) > + unsigned long len, unsigned long mmap_flags, > + vm_flags_t vm_flags, unsigned long pgoff) > { > struct mm_struct *mm = current->mm; > struct vm_area_struct *vma, *prev; > @@ -1448,7 +1449,10 @@ unsigned long mmap_region(struct file *file, unsigned > long addr, > /* Clear old maps */ > while (find_vma_links(mm, addr, addr + len, , _link, > _parent)) { > - if (do_munmap(mm, addr, len)) > + const bool dont_unmap = > + (mmap_flags & (MAP_DONTUNMAP | MAP_FIXED)) > + == (MAP_DONTUNMAP | MAP_FIXED); > + if (dont_unmap || do_munmap(mm, addr, len)) > return -ENOMEM; > } > > -- > 2.7.4 >
Re: [PATCH 0/3] mm/mmap.c: don't unmap the overlapping VMA(s)
On Sat, Apr 2, 2016 at 10:17 PM, Piotr Kwapulinski wrote: > Currently the mmap(MAP_FIXED) discards the overlapping part of the > existing VMA(s). > Introduce the new MAP_DONTUNMAP flag which forces the mmap to fail > with ENOMEM whenever the overlapping occurs and MAP_FIXED is set. > No existing mapping(s) is discarded. How userspace is supposed to use this and handle failure? For now you can get the same behavior in couple syscalls: mmap without MAP_FIXED if resulting address differs unmmap and handle error. Twice slower but this is error-path so you anyway have to some extra actions. > The implementation tests the MAP_DONTUNMAP flag right before unmapping > the VMA. The tile arch is the dependency of mmap_flags. > > I did the isolated tests and also tested it with Gentoo full > installation. > > Signed-off-by: Piotr Kwapulinski > --- > arch/tile/mm/elf.c | 1 + > include/linux/mm.h | 3 ++- > include/uapi/asm-generic/mman-common.h | 1 + > mm/mmap.c | 10 +++--- > 4 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/arch/tile/mm/elf.c b/arch/tile/mm/elf.c > index 6225cc9..dae4b33 100644 > --- a/arch/tile/mm/elf.c > +++ b/arch/tile/mm/elf.c > @@ -142,6 +142,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, > if (!retval) { > unsigned long addr = MEM_USER_INTRPT; > addr = mmap_region(NULL, addr, INTRPT_SIZE, > + MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE, >VM_READ|VM_EXEC| >VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 0); > if (addr > (unsigned long) -PAGE_SIZE) > diff --git a/include/linux/mm.h b/include/linux/mm.h > index ed6407d..31dcdfb 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2048,7 +2048,8 @@ extern int install_special_mapping(struct mm_struct *mm, > extern unsigned long get_unmapped_area(struct file *, unsigned long, > unsigned long, unsigned long, unsigned long); > > extern unsigned long mmap_region(struct file *file, unsigned long addr, > - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff); > + unsigned long len, unsigned long mmap_flags, > + vm_flags_t vm_flags, unsigned long pgoff); > extern unsigned long do_mmap(struct file *file, unsigned long addr, > unsigned long len, unsigned long prot, unsigned long flags, > vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate); > diff --git a/include/uapi/asm-generic/mman-common.h > b/include/uapi/asm-generic/mman-common.h > index 5827438..3655be3 100644 > --- a/include/uapi/asm-generic/mman-common.h > +++ b/include/uapi/asm-generic/mman-common.h > @@ -19,6 +19,7 @@ > #define MAP_TYPE 0x0f/* Mask for type of mapping */ > #define MAP_FIXED 0x10/* Interpret addr exactly */ > #define MAP_ANONYMOUS 0x20/* don't use a file */ > +#define MAP_DONTUNMAP 0x40/* don't unmap overlapping VMA */ > #ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED > # define MAP_UNINITIALIZED 0x400 /* For anonymous mmap, memory could > be uninitialized */ > #else > diff --git a/mm/mmap.c b/mm/mmap.c > index bd2e1a53..ab429c3 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -1286,7 +1286,7 @@ unsigned long do_mmap(struct file *file, unsigned long > addr, > vm_flags |= VM_NORESERVE; > } > > - addr = mmap_region(file, addr, len, vm_flags, pgoff); > + addr = mmap_region(file, addr, len, flags, vm_flags, pgoff); > if (!IS_ERR_VALUE(addr) && > ((vm_flags & VM_LOCKED) || > (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE)) > @@ -1422,7 +1422,8 @@ static inline int accountable_mapping(struct file > *file, vm_flags_t vm_flags) > } > > unsigned long mmap_region(struct file *file, unsigned long addr, > - unsigned long len, vm_flags_t vm_flags, unsigned long pgoff) > + unsigned long len, unsigned long mmap_flags, > + vm_flags_t vm_flags, unsigned long pgoff) > { > struct mm_struct *mm = current->mm; > struct vm_area_struct *vma, *prev; > @@ -1448,7 +1449,10 @@ unsigned long mmap_region(struct file *file, unsigned > long addr, > /* Clear old maps */ > while (find_vma_links(mm, addr, addr + len, , _link, > _parent)) { > - if (do_munmap(mm, addr, len)) > + const bool dont_unmap = > + (mmap_flags & (MAP_DONTUNMAP | MAP_FIXED)) > + == (MAP_DONTUNMAP | MAP_FIXED); > + if (dont_unmap || do_munmap(mm, addr, len)) > return -ENOMEM; > } > > -- > 2.7.4 >
[PATCH] mm/mmap: kill hook arch_rebalance_pgtables
Nobody use it. Signed-off-by: Konstantin Khlebnikov--- mm/mmap.c |5 - 1 file changed, 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index bd2e1a533bc1..fba246b8f1a5 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -55,10 +55,6 @@ #define arch_mmap_check(addr, len, flags) (0) #endif -#ifndef arch_rebalance_pgtables -#define arch_rebalance_pgtables(addr, len) (addr) -#endif - #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS const int mmap_rnd_bits_min = CONFIG_ARCH_MMAP_RND_BITS_MIN; const int mmap_rnd_bits_max = CONFIG_ARCH_MMAP_RND_BITS_MAX; @@ -1911,7 +1907,6 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, if (offset_in_page(addr)) return -EINVAL; - addr = arch_rebalance_pgtables(addr, len); error = security_mmap_addr(addr); return error ? error : addr; }
[PATCH] mm/mmap: kill hook arch_rebalance_pgtables
Nobody use it. Signed-off-by: Konstantin Khlebnikov --- mm/mmap.c |5 - 1 file changed, 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index bd2e1a533bc1..fba246b8f1a5 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -55,10 +55,6 @@ #define arch_mmap_check(addr, len, flags) (0) #endif -#ifndef arch_rebalance_pgtables -#define arch_rebalance_pgtables(addr, len) (addr) -#endif - #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS const int mmap_rnd_bits_min = CONFIG_ARCH_MMAP_RND_BITS_MIN; const int mmap_rnd_bits_max = CONFIG_ARCH_MMAP_RND_BITS_MAX; @@ -1911,7 +1907,6 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, if (offset_in_page(addr)) return -EINVAL; - addr = arch_rebalance_pgtables(addr, len); error = security_mmap_addr(addr); return error ? error : addr; }
[PATCH 06/13] fscrypto: crypto_alloc_skcipher() always returns an ERR_PTR(), never NULL
Signed-off-by: Eric Biggers--- fs/crypto/keyinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 33296c0..cb06351 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -208,8 +208,8 @@ retry: goto out; got_key: ctfm = crypto_alloc_skcipher(cipher_str, 0, 0); - if (!ctfm || IS_ERR(ctfm)) { - res = ctfm ? PTR_ERR(ctfm) : -ENOMEM; + if (IS_ERR(ctfm)) { + res = PTR_ERR(ctfm); printk(KERN_DEBUG "%s: error %d (inode %u) allocating crypto tfm\n", __func__, res, (unsigned) inode->i_ino); -- 2.7.4
[PATCH 01/13] fscrypto: remove unnecessary includes
Signed-off-by: Eric Biggers--- fs/crypto/crypto.c | 1 - fs/crypto/fname.c | 2 -- fs/crypto/keyinfo.c | 3 --- 3 files changed, 6 deletions(-) diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 06cd1a2..2c7923d 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -27,7 +27,6 @@ #include #include #include -#include static unsigned int num_prealloc_crypto_pages = 32; static unsigned int num_prealloc_crypto_ctxs = 128; diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 5d6d491..3108806 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -10,8 +10,6 @@ * This has not yet undergone a rigorous security audit. */ -#include -#include #include #include #include diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 06f5aa4..03d2b0d 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -8,11 +8,8 @@ * Written by Michael Halcrow, Ildar Muslukhov, and Uday Savagaonkar, 2015. */ -#include #include -#include #include -#include #include static void derive_crypt_complete(struct crypto_async_request *req, int rc) -- 2.7.4
[PATCH 05/13] fscrypto: comment improvements and fixes
Signed-off-by: Eric Biggers--- fs/crypto/crypto.c | 13 ++-- fs/crypto/fname.c| 33 ++ fs/crypto/keyinfo.c | 8 include/linux/fscrypto.h | 53 ++-- 4 files changed, 90 insertions(+), 17 deletions(-) diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 6e550ec..836c0f2 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -83,8 +83,8 @@ EXPORT_SYMBOL(fscrypt_release_ctx); * * Allocates and initializes an encryption context. * - * Return: An allocated and initialized encryption context on success; error - * value or NULL otherwise. + * Return: An allocated and initialized encryption context on success; an error + * value otherwise. */ struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode) { @@ -222,7 +222,7 @@ static struct page *alloc_bounce_page(struct fscrypt_ctx *ctx) * release the bounce buffer and the encryption context. * * Return: An allocated page with the encrypted content on success. Else, an - * error value or NULL. + * error value. */ struct page *fscrypt_encrypt_page(struct inode *inode, struct page *plaintext_page) @@ -261,10 +261,10 @@ errout: EXPORT_SYMBOL(fscrypt_encrypt_page); /** - * f2crypt_decrypt_page() - Decrypts a page in-place + * fscrypt_decrypt_page() - Decrypts a page in-place * @page: The page to decrypt. Must be locked. * - * Decrypts page in-place using the ctx encryption context. + * Decrypts a page in-place using the host inode's encryption context. * * Called from the read completion callback. * @@ -358,7 +358,6 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) (1 << KEY_FLAG_DEAD ci = NULL; - /* this should eventually be an flag in d_flags */ spin_lock(>d_lock); cached_with_key = dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY; spin_unlock(>d_lock); @@ -368,7 +367,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) * If the dentry was cached without the key, and it is a * negative dentry, it might be a valid name. We can't check * if the key has since been made available due to locking -* reasons, so we fail the validation so ext4_lookup() can do +* reasons, so we fail the validation so ->lookup() can do * this check. * * We also fail the validation if the dentry was created with diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index ceaa815..cd0eae8 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -178,8 +178,11 @@ static const char *lookup_table = /** * digest_encode() - * - * Encodes the input digest using characters from the set [a-zA-Z0-9_+]. + * Encodes the input digest using characters from the set [A-Za-z0-9+,]. * The encoded string is roughly 4/3 times the size of the input string. + * + * Note that the result of this encoding is for presentation purposes only; it + * is not persisted in the filesystem. */ static int digest_encode(const char *src, int len, char *dst) { @@ -239,7 +242,7 @@ u32 fscrypt_fname_encrypted_size(struct inode *inode, u32 ilen) EXPORT_SYMBOL(fscrypt_fname_encrypted_size); /** - * fscrypt_fname_crypto_alloc_obuff() - + * fscrypt_fname_alloc_buffer() - * * Allocates an output buffer that is sufficient for the crypto operation * specified by the context and the direction. @@ -264,7 +267,7 @@ int fscrypt_fname_alloc_buffer(struct inode *inode, EXPORT_SYMBOL(fscrypt_fname_alloc_buffer); /** - * fscrypt_fname_crypto_free_buffer() - + * fscrypt_fname_free_buffer() - * * Frees the buffer allocated for crypto operation. */ @@ -280,6 +283,12 @@ EXPORT_SYMBOL(fscrypt_fname_free_buffer); /** * fscrypt_fname_disk_to_usr() - converts a filename from disk space to user * space + * + * The caller must have used fscrypt_fname_alloc_buffer() to allocate sufficient + * memory for the @oname string. Also, fscrypt_load_encryption_info() must have + * been already called on the inode. + * + * Return: the length of the user space name or a negative errno value. */ int fscrypt_fname_disk_to_usr(struct inode *inode, u32 hash, u32 minor_hash, @@ -290,6 +299,7 @@ int fscrypt_fname_disk_to_usr(struct inode *inode, char buf[24]; int ret; + /* Leave . and .. alone. */ if (fscrypt_is_dot_dotdot()) { oname->name[0] = '.'; oname->name[iname->len - 1] = '.'; @@ -300,14 +310,19 @@ int fscrypt_fname_disk_to_usr(struct inode *inode, if (iname->len < FS_CRYPTO_BLOCK_SIZE) return -EUCLEAN; + /* Decrypt the name if we have the key. */ if (inode->i_crypt_info) return fname_decrypt(inode, iname, oname); if (iname->len <= FS_FNAME_CRYPTO_DIGEST_SIZE) {
[PATCH 06/13] fscrypto: crypto_alloc_skcipher() always returns an ERR_PTR(), never NULL
Signed-off-by: Eric Biggers --- fs/crypto/keyinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 33296c0..cb06351 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -208,8 +208,8 @@ retry: goto out; got_key: ctfm = crypto_alloc_skcipher(cipher_str, 0, 0); - if (!ctfm || IS_ERR(ctfm)) { - res = ctfm ? PTR_ERR(ctfm) : -ENOMEM; + if (IS_ERR(ctfm)) { + res = PTR_ERR(ctfm); printk(KERN_DEBUG "%s: error %d (inode %u) allocating crypto tfm\n", __func__, res, (unsigned) inode->i_ino); -- 2.7.4
[PATCH 01/13] fscrypto: remove unnecessary includes
Signed-off-by: Eric Biggers --- fs/crypto/crypto.c | 1 - fs/crypto/fname.c | 2 -- fs/crypto/keyinfo.c | 3 --- 3 files changed, 6 deletions(-) diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 06cd1a2..2c7923d 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -27,7 +27,6 @@ #include #include #include -#include static unsigned int num_prealloc_crypto_pages = 32; static unsigned int num_prealloc_crypto_ctxs = 128; diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 5d6d491..3108806 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -10,8 +10,6 @@ * This has not yet undergone a rigorous security audit. */ -#include -#include #include #include #include diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 06f5aa4..03d2b0d 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -8,11 +8,8 @@ * Written by Michael Halcrow, Ildar Muslukhov, and Uday Savagaonkar, 2015. */ -#include #include -#include #include -#include #include static void derive_crypt_complete(struct crypto_async_request *req, int rc) -- 2.7.4
[PATCH 05/13] fscrypto: comment improvements and fixes
Signed-off-by: Eric Biggers --- fs/crypto/crypto.c | 13 ++-- fs/crypto/fname.c| 33 ++ fs/crypto/keyinfo.c | 8 include/linux/fscrypto.h | 53 ++-- 4 files changed, 90 insertions(+), 17 deletions(-) diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 6e550ec..836c0f2 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -83,8 +83,8 @@ EXPORT_SYMBOL(fscrypt_release_ctx); * * Allocates and initializes an encryption context. * - * Return: An allocated and initialized encryption context on success; error - * value or NULL otherwise. + * Return: An allocated and initialized encryption context on success; an error + * value otherwise. */ struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode) { @@ -222,7 +222,7 @@ static struct page *alloc_bounce_page(struct fscrypt_ctx *ctx) * release the bounce buffer and the encryption context. * * Return: An allocated page with the encrypted content on success. Else, an - * error value or NULL. + * error value. */ struct page *fscrypt_encrypt_page(struct inode *inode, struct page *plaintext_page) @@ -261,10 +261,10 @@ errout: EXPORT_SYMBOL(fscrypt_encrypt_page); /** - * f2crypt_decrypt_page() - Decrypts a page in-place + * fscrypt_decrypt_page() - Decrypts a page in-place * @page: The page to decrypt. Must be locked. * - * Decrypts page in-place using the ctx encryption context. + * Decrypts a page in-place using the host inode's encryption context. * * Called from the read completion callback. * @@ -358,7 +358,6 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) (1 << KEY_FLAG_DEAD ci = NULL; - /* this should eventually be an flag in d_flags */ spin_lock(>d_lock); cached_with_key = dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY; spin_unlock(>d_lock); @@ -368,7 +367,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) * If the dentry was cached without the key, and it is a * negative dentry, it might be a valid name. We can't check * if the key has since been made available due to locking -* reasons, so we fail the validation so ext4_lookup() can do +* reasons, so we fail the validation so ->lookup() can do * this check. * * We also fail the validation if the dentry was created with diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index ceaa815..cd0eae8 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -178,8 +178,11 @@ static const char *lookup_table = /** * digest_encode() - * - * Encodes the input digest using characters from the set [a-zA-Z0-9_+]. + * Encodes the input digest using characters from the set [A-Za-z0-9+,]. * The encoded string is roughly 4/3 times the size of the input string. + * + * Note that the result of this encoding is for presentation purposes only; it + * is not persisted in the filesystem. */ static int digest_encode(const char *src, int len, char *dst) { @@ -239,7 +242,7 @@ u32 fscrypt_fname_encrypted_size(struct inode *inode, u32 ilen) EXPORT_SYMBOL(fscrypt_fname_encrypted_size); /** - * fscrypt_fname_crypto_alloc_obuff() - + * fscrypt_fname_alloc_buffer() - * * Allocates an output buffer that is sufficient for the crypto operation * specified by the context and the direction. @@ -264,7 +267,7 @@ int fscrypt_fname_alloc_buffer(struct inode *inode, EXPORT_SYMBOL(fscrypt_fname_alloc_buffer); /** - * fscrypt_fname_crypto_free_buffer() - + * fscrypt_fname_free_buffer() - * * Frees the buffer allocated for crypto operation. */ @@ -280,6 +283,12 @@ EXPORT_SYMBOL(fscrypt_fname_free_buffer); /** * fscrypt_fname_disk_to_usr() - converts a filename from disk space to user * space + * + * The caller must have used fscrypt_fname_alloc_buffer() to allocate sufficient + * memory for the @oname string. Also, fscrypt_load_encryption_info() must have + * been already called on the inode. + * + * Return: the length of the user space name or a negative errno value. */ int fscrypt_fname_disk_to_usr(struct inode *inode, u32 hash, u32 minor_hash, @@ -290,6 +299,7 @@ int fscrypt_fname_disk_to_usr(struct inode *inode, char buf[24]; int ret; + /* Leave . and .. alone. */ if (fscrypt_is_dot_dotdot()) { oname->name[0] = '.'; oname->name[iname->len - 1] = '.'; @@ -300,14 +310,19 @@ int fscrypt_fname_disk_to_usr(struct inode *inode, if (iname->len < FS_CRYPTO_BLOCK_SIZE) return -EUCLEAN; + /* Decrypt the name if we have the key. */ if (inode->i_crypt_info) return fname_decrypt(inode, iname, oname); if (iname->len <= FS_FNAME_CRYPTO_DIGEST_SIZE) { + /*
fs/xfs/xfs_ondisk.h:86:2: error: call to '__compiletime_assert_86' declared with attribute error: XFS: sizeof(xfs_dir2_data_unused_t) is wrong, expected 6
Hi Dave, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: ab9d1e4f7b0217948a3b35a64178602ab30ff45d Merge branch 'xfs-misc-fixes-4.6-3' into for-next date: 4 weeks ago config: openrisc-allyesconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout ab9d1e4f7b0217948a3b35a64178602ab30ff45d # save the attached .config to linux build tree make.cross ARCH=openrisc All errors (new ones prefixed by >>): In file included from fs/xfs/xfs_super.c:48:0: In function 'xfs_check_ondisk_structs', inlined from 'init_xfs_fs' at fs/xfs/xfs_super.c:1862:26: >> fs/xfs/xfs_ondisk.h:86:2: error: call to '__compiletime_assert_86' declared >> with attribute error: XFS: sizeof(xfs_dir2_data_unused_t) is wrong, expected >> 6 >> fs/xfs/xfs_ondisk.h:96:2: error: call to '__compiletime_assert_96' declared >> with attribute error: XFS: sizeof(xfs_dir2_sf_entry_t) is wrong, expected 3 >> fs/xfs/xfs_ondisk.h:97:2: error: call to '__compiletime_assert_97' declared >> with attribute error: XFS: sizeof(xfs_dir2_sf_hdr_t) is wrong, expected 10 vim +/__compiletime_assert_86 +86 fs/xfs/xfs_ondisk.h 30cbc591 Darrick J. Wong 2016-03-09 80 XFS_CHECK_STRUCT_SIZE(xfs_da_blkinfo_t, 12); 30cbc591 Darrick J. Wong 2016-03-09 81 XFS_CHECK_STRUCT_SIZE(xfs_da_intnode_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 82 XFS_CHECK_STRUCT_SIZE(xfs_da_node_entry_t, 8); 30cbc591 Darrick J. Wong 2016-03-09 83 XFS_CHECK_STRUCT_SIZE(xfs_da_node_hdr_t,16); 30cbc591 Darrick J. Wong 2016-03-09 84 XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_free_t, 4); 30cbc591 Darrick J. Wong 2016-03-09 85 XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_hdr_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 @86 XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_unused_t, 6); 30cbc591 Darrick J. Wong 2016-03-09 87 XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 88 XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 89 XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino4_t, 4); 30cbc591 Darrick J. Wong 2016-03-09 90 XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino8_t, 8); 30cbc591 Darrick J. Wong 2016-03-09 91 XFS_CHECK_STRUCT_SIZE(xfs_dir2_inou_t, 8); 30cbc591 Darrick J. Wong 2016-03-09 92 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_entry_t,8); 30cbc591 Darrick J. Wong 2016-03-09 93 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 94 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 95 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4); 30cbc591 Darrick J. Wong 2016-03-09 @96 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3); 30cbc591 Darrick J. Wong 2016-03-09 @97 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t,10); 30cbc591 Darrick J. Wong 2016-03-09 98 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t,2); 30cbc591 Darrick J. Wong 2016-03-09 99 30cbc591 Darrick J. Wong 2016-03-09 100/* log structures */ :: The code at line 86 was first introduced by commit :: 30cbc591c34e680e8b5d6d675ea49effe42a0570 xfs: check sizes of XFS on-disk structures at compile time :: TO: Darrick J. Wong:: CC: Dave Chinner --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
fs/xfs/xfs_ondisk.h:86:2: error: call to '__compiletime_assert_86' declared with attribute error: XFS: sizeof(xfs_dir2_data_unused_t) is wrong, expected 6
Hi Dave, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: ab9d1e4f7b0217948a3b35a64178602ab30ff45d Merge branch 'xfs-misc-fixes-4.6-3' into for-next date: 4 weeks ago config: openrisc-allyesconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout ab9d1e4f7b0217948a3b35a64178602ab30ff45d # save the attached .config to linux build tree make.cross ARCH=openrisc All errors (new ones prefixed by >>): In file included from fs/xfs/xfs_super.c:48:0: In function 'xfs_check_ondisk_structs', inlined from 'init_xfs_fs' at fs/xfs/xfs_super.c:1862:26: >> fs/xfs/xfs_ondisk.h:86:2: error: call to '__compiletime_assert_86' declared >> with attribute error: XFS: sizeof(xfs_dir2_data_unused_t) is wrong, expected >> 6 >> fs/xfs/xfs_ondisk.h:96:2: error: call to '__compiletime_assert_96' declared >> with attribute error: XFS: sizeof(xfs_dir2_sf_entry_t) is wrong, expected 3 >> fs/xfs/xfs_ondisk.h:97:2: error: call to '__compiletime_assert_97' declared >> with attribute error: XFS: sizeof(xfs_dir2_sf_hdr_t) is wrong, expected 10 vim +/__compiletime_assert_86 +86 fs/xfs/xfs_ondisk.h 30cbc591 Darrick J. Wong 2016-03-09 80 XFS_CHECK_STRUCT_SIZE(xfs_da_blkinfo_t, 12); 30cbc591 Darrick J. Wong 2016-03-09 81 XFS_CHECK_STRUCT_SIZE(xfs_da_intnode_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 82 XFS_CHECK_STRUCT_SIZE(xfs_da_node_entry_t, 8); 30cbc591 Darrick J. Wong 2016-03-09 83 XFS_CHECK_STRUCT_SIZE(xfs_da_node_hdr_t,16); 30cbc591 Darrick J. Wong 2016-03-09 84 XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_free_t, 4); 30cbc591 Darrick J. Wong 2016-03-09 85 XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_hdr_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 @86 XFS_CHECK_STRUCT_SIZE(xfs_dir2_data_unused_t, 6); 30cbc591 Darrick J. Wong 2016-03-09 87 XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_hdr_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 88 XFS_CHECK_STRUCT_SIZE(xfs_dir2_free_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 89 XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino4_t, 4); 30cbc591 Darrick J. Wong 2016-03-09 90 XFS_CHECK_STRUCT_SIZE(xfs_dir2_ino8_t, 8); 30cbc591 Darrick J. Wong 2016-03-09 91 XFS_CHECK_STRUCT_SIZE(xfs_dir2_inou_t, 8); 30cbc591 Darrick J. Wong 2016-03-09 92 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_entry_t,8); 30cbc591 Darrick J. Wong 2016-03-09 93 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_hdr_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 94 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_t, 16); 30cbc591 Darrick J. Wong 2016-03-09 95 XFS_CHECK_STRUCT_SIZE(xfs_dir2_leaf_tail_t, 4); 30cbc591 Darrick J. Wong 2016-03-09 @96 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t, 3); 30cbc591 Darrick J. Wong 2016-03-09 @97 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_hdr_t,10); 30cbc591 Darrick J. Wong 2016-03-09 98 XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_off_t,2); 30cbc591 Darrick J. Wong 2016-03-09 99 30cbc591 Darrick J. Wong 2016-03-09 100/* log structures */ :: The code at line 86 was first introduced by commit :: 30cbc591c34e680e8b5d6d675ea49effe42a0570 xfs: check sizes of XFS on-disk structures at compile time :: TO: Darrick J. Wong :: CC: Dave Chinner --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH 02/13] fscrypto: rename some functions for clarity
Rename fscrypt_complete() to page_crypt_complete(). This callback is specifically for data pages; fscrypto also performs filename encryption. Rename dir_crypt_complete() to fname_crypt_complete(). This callback is also used for symlink targets, not just directory entries. Rename fscrypt_process_policy() to fscrypt_set_policy(). The new name better matches the ioctl, and it goes along with fscrypt_get_policy(). Signed-off-by: Eric Biggers--- fs/crypto/crypto.c | 11 ++- fs/crypto/fname.c| 11 +++ fs/crypto/policy.c | 5 ++--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- include/linux/fscrypto.h | 5 ++--- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 2c7923d..6e550ec 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -125,11 +125,12 @@ struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode) EXPORT_SYMBOL(fscrypt_get_ctx); /** - * fscrypt_complete() - The completion callback for page encryption - * @req: The asynchronous encryption request context - * @res: The result of the encryption operation + * page_crypt_complete() - The completion callback for page encryption and + *decryption + * @req: The asynchronous cipher request context + * @res: The result of the cipher operation */ -static void fscrypt_complete(struct crypto_async_request *req, int res) +static void page_crypt_complete(struct crypto_async_request *req, int res) { struct fscrypt_completion_result *ecr = req->data; @@ -166,7 +167,7 @@ static int do_page_crypto(struct inode *inode, skcipher_request_set_callback( req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - fscrypt_complete, ); + page_crypt_complete, ); BUILD_BUG_ON(FS_XTS_TWEAK_SIZE < sizeof(index)); memcpy(xts_tweak, , sizeof(index)); diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 3108806..c3e3554 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -20,9 +20,12 @@ static u32 size_round_up(size_t size, size_t blksize) } /** - * dir_crypt_complete() - + * fname_crypt_complete() - The completion callback for filename encryption and + * decryption + * @req: The asynchronous cipher request context + * @res: The result of the cipher operation */ -static void dir_crypt_complete(struct crypto_async_request *req, int res) +static void fname_crypt_complete(struct crypto_async_request *req, int res) { struct fscrypt_completion_result *ecr = req->data; @@ -82,7 +85,7 @@ static int fname_encrypt(struct inode *inode, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - dir_crypt_complete, ); + fname_crypt_complete, ); /* Copy the input */ memcpy(workbuf, iname->name, iname->len); @@ -144,7 +147,7 @@ static int fname_decrypt(struct inode *inode, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - dir_crypt_complete, ); + fname_crypt_complete, ); /* Initialize IV */ memset(iv, 0, FS_CRYPTO_BLOCK_SIZE); diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 0f9961e..e1d263d 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -92,8 +92,7 @@ static int create_encryption_context_from_policy(struct inode *inode, return inode->i_sb->s_cop->set_context(inode, , sizeof(ctx), NULL); } -int fscrypt_process_policy(struct inode *inode, - const struct fscrypt_policy *policy) +int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) { if (policy->version != 0) return -EINVAL; @@ -113,7 +112,7 @@ int fscrypt_process_policy(struct inode *inode, __func__); return -EINVAL; } -EXPORT_SYMBOL(fscrypt_process_policy); +EXPORT_SYMBOL(fscrypt_set_policy); int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy) { diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index bbe2cd1..970678d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2172,7 +2172,7 @@ static inline bool f2fs_may_encrypt(struct inode *inode) #define fscrypt_pullback_bio_page fscrypt_notsupp_pullback_bio_page #define fscrypt_restore_control_page fscrypt_notsupp_restore_control_page #define fscrypt_zeroout_range fscrypt_notsupp_zeroout_range -#define fscrypt_process_policy fscrypt_notsupp_process_policy +#define fscrypt_set_policy fscrypt_notsupp_set_policy #define fscrypt_get_policy fscrypt_notsupp_get_policy #define fscrypt_has_permitted_context fscrypt_notsupp_has_permitted_context #define fscrypt_inherit_contextfscrypt_notsupp_inherit_context diff
[PATCH 00/13] fscrypto: cleanups and fixes
This patchset includes various cleanups for the new filesystem encryption code as well as some bug fixes for the FS_IOC_SET_ENCRYPTION_POLICY ioctl. Eric Biggers (13): fscrypto: remove unnecessary includes fscrypto: rename some functions for clarity fscrypto: rename functions to load and unload inode encryption info fscrypto: return bool instead of int where appropriate fscrypto: comment improvements and fixes fscrypto: crypto_alloc_skcipher() always returns an ERR_PTR(), never NULL fscrypto: simplify building key descriptor string fscrypto: use standard macros from kernel.h fscrypto: make fname_encrypt() actually return length of ciphertext fscrypto: restrict setting new policy to empty files and directories only fscrypto: restrict setting encryption policy to inode owner fscrypto: require write access to mount to set encryption policy fscrypto: improve error handling in fscrypt_set_policy() fs/crypto/crypto.c | 25 + fs/crypto/fname.c| 72 -- fs/crypto/keyinfo.c | 47 - fs/crypto/policy.c | 131 +++ fs/f2fs/dir.c| 4 +- fs/f2fs/f2fs.h | 6 +-- fs/f2fs/file.c | 10 ++-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 10 ++-- fs/f2fs/super.c | 2 +- include/linux/fscrypto.h | 81 + 11 files changed, 236 insertions(+), 154 deletions(-) -- 2.7.4
[PATCH 04/13] fscrypto: return bool instead of int where appropriate
Signed-off-by: Eric Biggers--- fs/crypto/policy.c | 24 include/linux/fscrypto.h | 12 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 03a2f50..93244b5 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -12,10 +12,10 @@ #include #include -static int inode_has_encryption_context(struct inode *inode) +static bool inode_has_encryption_context(struct inode *inode) { if (!inode->i_sb->s_cop->get_context) - return 0; + return false; return (inode->i_sb->s_cop->get_context(inode, NULL, 0L) > 0); } @@ -23,18 +23,18 @@ static int inode_has_encryption_context(struct inode *inode) * check whether the policy is consistent with the encryption context * for the inode */ -static int is_encryption_context_consistent_with_policy(struct inode *inode, +static bool is_encryption_context_consistent_with_policy(struct inode *inode, const struct fscrypt_policy *policy) { struct fscrypt_context ctx; int res; if (!inode->i_sb->s_cop->get_context) - return 0; + return false; res = inode->i_sb->s_cop->get_context(inode, , sizeof(ctx)); if (res != sizeof(ctx)) - return 0; + return false; return (memcmp(ctx.master_key_descriptor, policy->master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE) == 0 && @@ -139,7 +139,7 @@ int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy) } EXPORT_SYMBOL(fscrypt_get_policy); -int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) +bool fscrypt_has_permitted_context(struct inode *parent, struct inode *child) { struct fscrypt_info *parent_ci, *child_ci; int res; @@ -151,22 +151,22 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) /* no restrictions if the parent directory is not encrypted */ if (!parent->i_sb->s_cop->is_encrypted(parent)) - return 1; + return true; /* if the child directory is not encrypted, this is always a problem */ if (!parent->i_sb->s_cop->is_encrypted(child)) - return 0; + return false; res = fscrypt_load_encryption_info(parent); if (res) - return 0; + return false; res = fscrypt_load_encryption_info(child); if (res) - return 0; + return false; parent_ci = parent->i_crypt_info; child_ci = child->i_crypt_info; if (!parent_ci && !child_ci) - return 1; + return true; if (!parent_ci || !child_ci) - return 0; + return false; return (memcmp(parent_ci->ci_master_key, child_ci->ci_master_key, diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h index 1bf00a5..9a32d7e 100644 --- a/include/linux/fscrypto.h +++ b/include/linux/fscrypto.h @@ -177,7 +177,7 @@ struct fscrypt_operations { int (*get_context)(struct inode *, void *, size_t); int (*prepare_context)(struct inode *); int (*set_context)(struct inode *, const void *, size_t, void *); - int (*dummy_context)(struct inode *); + bool (*dummy_context)(struct inode *); bool (*is_encrypted)(struct inode *); bool (*empty_dir)(struct inode *); unsigned (*max_namelen)(struct inode *); @@ -229,12 +229,12 @@ static inline struct page *fscrypt_control_page(struct page *page) #endif } -static inline int fscrypt_has_encryption_key(struct inode *inode) +static inline bool fscrypt_has_encryption_key(struct inode *inode) { #if IS_ENABLED(CONFIG_FS_ENCRYPTION) return (inode->i_crypt_info != NULL); #else - return 0; + return false; #endif } @@ -275,7 +275,7 @@ extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, /* policy.c */ extern int fscrypt_set_policy(struct inode *, const struct fscrypt_policy *); extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); -extern int fscrypt_has_permitted_context(struct inode *, struct inode *); +extern bool fscrypt_has_permitted_context(struct inode *, struct inode *); extern int fscrypt_inherit_context(struct inode *, struct inode *, void *, bool); /* keyinfo.c */ @@ -355,10 +355,10 @@ static inline int fscrypt_notsupp_get_policy(struct inode *i, return -EOPNOTSUPP; } -static inline int fscrypt_notsupp_has_permitted_context(struct inode *p, +static inline bool fscrypt_notsupp_has_permitted_context(struct inode *p, struct inode *i) { - return 0; + return false; } static inline int fscrypt_notsupp_inherit_context(struct inode *p, -- 2.7.4
[PATCH 02/13] fscrypto: rename some functions for clarity
Rename fscrypt_complete() to page_crypt_complete(). This callback is specifically for data pages; fscrypto also performs filename encryption. Rename dir_crypt_complete() to fname_crypt_complete(). This callback is also used for symlink targets, not just directory entries. Rename fscrypt_process_policy() to fscrypt_set_policy(). The new name better matches the ioctl, and it goes along with fscrypt_get_policy(). Signed-off-by: Eric Biggers --- fs/crypto/crypto.c | 11 ++- fs/crypto/fname.c| 11 +++ fs/crypto/policy.c | 5 ++--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- include/linux/fscrypto.h | 5 ++--- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 2c7923d..6e550ec 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -125,11 +125,12 @@ struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode) EXPORT_SYMBOL(fscrypt_get_ctx); /** - * fscrypt_complete() - The completion callback for page encryption - * @req: The asynchronous encryption request context - * @res: The result of the encryption operation + * page_crypt_complete() - The completion callback for page encryption and + *decryption + * @req: The asynchronous cipher request context + * @res: The result of the cipher operation */ -static void fscrypt_complete(struct crypto_async_request *req, int res) +static void page_crypt_complete(struct crypto_async_request *req, int res) { struct fscrypt_completion_result *ecr = req->data; @@ -166,7 +167,7 @@ static int do_page_crypto(struct inode *inode, skcipher_request_set_callback( req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - fscrypt_complete, ); + page_crypt_complete, ); BUILD_BUG_ON(FS_XTS_TWEAK_SIZE < sizeof(index)); memcpy(xts_tweak, , sizeof(index)); diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 3108806..c3e3554 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -20,9 +20,12 @@ static u32 size_round_up(size_t size, size_t blksize) } /** - * dir_crypt_complete() - + * fname_crypt_complete() - The completion callback for filename encryption and + * decryption + * @req: The asynchronous cipher request context + * @res: The result of the cipher operation */ -static void dir_crypt_complete(struct crypto_async_request *req, int res) +static void fname_crypt_complete(struct crypto_async_request *req, int res) { struct fscrypt_completion_result *ecr = req->data; @@ -82,7 +85,7 @@ static int fname_encrypt(struct inode *inode, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - dir_crypt_complete, ); + fname_crypt_complete, ); /* Copy the input */ memcpy(workbuf, iname->name, iname->len); @@ -144,7 +147,7 @@ static int fname_decrypt(struct inode *inode, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - dir_crypt_complete, ); + fname_crypt_complete, ); /* Initialize IV */ memset(iv, 0, FS_CRYPTO_BLOCK_SIZE); diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 0f9961e..e1d263d 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -92,8 +92,7 @@ static int create_encryption_context_from_policy(struct inode *inode, return inode->i_sb->s_cop->set_context(inode, , sizeof(ctx), NULL); } -int fscrypt_process_policy(struct inode *inode, - const struct fscrypt_policy *policy) +int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) { if (policy->version != 0) return -EINVAL; @@ -113,7 +112,7 @@ int fscrypt_process_policy(struct inode *inode, __func__); return -EINVAL; } -EXPORT_SYMBOL(fscrypt_process_policy); +EXPORT_SYMBOL(fscrypt_set_policy); int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy) { diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index bbe2cd1..970678d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2172,7 +2172,7 @@ static inline bool f2fs_may_encrypt(struct inode *inode) #define fscrypt_pullback_bio_page fscrypt_notsupp_pullback_bio_page #define fscrypt_restore_control_page fscrypt_notsupp_restore_control_page #define fscrypt_zeroout_range fscrypt_notsupp_zeroout_range -#define fscrypt_process_policy fscrypt_notsupp_process_policy +#define fscrypt_set_policy fscrypt_notsupp_set_policy #define fscrypt_get_policy fscrypt_notsupp_get_policy #define fscrypt_has_permitted_context fscrypt_notsupp_has_permitted_context #define fscrypt_inherit_contextfscrypt_notsupp_inherit_context diff --git
[PATCH 00/13] fscrypto: cleanups and fixes
This patchset includes various cleanups for the new filesystem encryption code as well as some bug fixes for the FS_IOC_SET_ENCRYPTION_POLICY ioctl. Eric Biggers (13): fscrypto: remove unnecessary includes fscrypto: rename some functions for clarity fscrypto: rename functions to load and unload inode encryption info fscrypto: return bool instead of int where appropriate fscrypto: comment improvements and fixes fscrypto: crypto_alloc_skcipher() always returns an ERR_PTR(), never NULL fscrypto: simplify building key descriptor string fscrypto: use standard macros from kernel.h fscrypto: make fname_encrypt() actually return length of ciphertext fscrypto: restrict setting new policy to empty files and directories only fscrypto: restrict setting encryption policy to inode owner fscrypto: require write access to mount to set encryption policy fscrypto: improve error handling in fscrypt_set_policy() fs/crypto/crypto.c | 25 + fs/crypto/fname.c| 72 -- fs/crypto/keyinfo.c | 47 - fs/crypto/policy.c | 131 +++ fs/f2fs/dir.c| 4 +- fs/f2fs/f2fs.h | 6 +-- fs/f2fs/file.c | 10 ++-- fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 10 ++-- fs/f2fs/super.c | 2 +- include/linux/fscrypto.h | 81 + 11 files changed, 236 insertions(+), 154 deletions(-) -- 2.7.4
[PATCH 04/13] fscrypto: return bool instead of int where appropriate
Signed-off-by: Eric Biggers --- fs/crypto/policy.c | 24 include/linux/fscrypto.h | 12 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 03a2f50..93244b5 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -12,10 +12,10 @@ #include #include -static int inode_has_encryption_context(struct inode *inode) +static bool inode_has_encryption_context(struct inode *inode) { if (!inode->i_sb->s_cop->get_context) - return 0; + return false; return (inode->i_sb->s_cop->get_context(inode, NULL, 0L) > 0); } @@ -23,18 +23,18 @@ static int inode_has_encryption_context(struct inode *inode) * check whether the policy is consistent with the encryption context * for the inode */ -static int is_encryption_context_consistent_with_policy(struct inode *inode, +static bool is_encryption_context_consistent_with_policy(struct inode *inode, const struct fscrypt_policy *policy) { struct fscrypt_context ctx; int res; if (!inode->i_sb->s_cop->get_context) - return 0; + return false; res = inode->i_sb->s_cop->get_context(inode, , sizeof(ctx)); if (res != sizeof(ctx)) - return 0; + return false; return (memcmp(ctx.master_key_descriptor, policy->master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE) == 0 && @@ -139,7 +139,7 @@ int fscrypt_get_policy(struct inode *inode, struct fscrypt_policy *policy) } EXPORT_SYMBOL(fscrypt_get_policy); -int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) +bool fscrypt_has_permitted_context(struct inode *parent, struct inode *child) { struct fscrypt_info *parent_ci, *child_ci; int res; @@ -151,22 +151,22 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) /* no restrictions if the parent directory is not encrypted */ if (!parent->i_sb->s_cop->is_encrypted(parent)) - return 1; + return true; /* if the child directory is not encrypted, this is always a problem */ if (!parent->i_sb->s_cop->is_encrypted(child)) - return 0; + return false; res = fscrypt_load_encryption_info(parent); if (res) - return 0; + return false; res = fscrypt_load_encryption_info(child); if (res) - return 0; + return false; parent_ci = parent->i_crypt_info; child_ci = child->i_crypt_info; if (!parent_ci && !child_ci) - return 1; + return true; if (!parent_ci || !child_ci) - return 0; + return false; return (memcmp(parent_ci->ci_master_key, child_ci->ci_master_key, diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h index 1bf00a5..9a32d7e 100644 --- a/include/linux/fscrypto.h +++ b/include/linux/fscrypto.h @@ -177,7 +177,7 @@ struct fscrypt_operations { int (*get_context)(struct inode *, void *, size_t); int (*prepare_context)(struct inode *); int (*set_context)(struct inode *, const void *, size_t, void *); - int (*dummy_context)(struct inode *); + bool (*dummy_context)(struct inode *); bool (*is_encrypted)(struct inode *); bool (*empty_dir)(struct inode *); unsigned (*max_namelen)(struct inode *); @@ -229,12 +229,12 @@ static inline struct page *fscrypt_control_page(struct page *page) #endif } -static inline int fscrypt_has_encryption_key(struct inode *inode) +static inline bool fscrypt_has_encryption_key(struct inode *inode) { #if IS_ENABLED(CONFIG_FS_ENCRYPTION) return (inode->i_crypt_info != NULL); #else - return 0; + return false; #endif } @@ -275,7 +275,7 @@ extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, /* policy.c */ extern int fscrypt_set_policy(struct inode *, const struct fscrypt_policy *); extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); -extern int fscrypt_has_permitted_context(struct inode *, struct inode *); +extern bool fscrypt_has_permitted_context(struct inode *, struct inode *); extern int fscrypt_inherit_context(struct inode *, struct inode *, void *, bool); /* keyinfo.c */ @@ -355,10 +355,10 @@ static inline int fscrypt_notsupp_get_policy(struct inode *i, return -EOPNOTSUPP; } -static inline int fscrypt_notsupp_has_permitted_context(struct inode *p, +static inline bool fscrypt_notsupp_has_permitted_context(struct inode *p, struct inode *i) { - return 0; + return false; } static inline int fscrypt_notsupp_inherit_context(struct inode *p, -- 2.7.4
[PATCH 03/13] fscrypto: rename functions to load and unload inode encryption info
Perform the following renamings: fscrypt_get_encryption_info() => fscrypt_load_encryption_info() fscrypt_put_encryption_info() => fscrypt_unload_encryption_info() get_crypt_info => load_crypt_info() put_crypt_info() => free_crypt_info() The new names better reflect the actual behavior where the "load" function just loads the fscrypt_info into i_crypto_info; it doesn't actually return it to the caller. There is also no reference counting involved, as might be suggested by the verbs "get" and "put". Signed-off-by: Eric Biggers--- fs/crypto/fname.c| 2 +- fs/crypto/keyinfo.c | 23 --- fs/crypto/policy.c | 8 fs/f2fs/dir.c| 4 ++-- fs/f2fs/f2fs.h | 4 ++-- fs/f2fs/file.c | 8 fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 10 +- fs/f2fs/super.c | 2 +- include/linux/fscrypto.h | 11 ++- 10 files changed, 38 insertions(+), 36 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index c3e3554..ceaa815 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -361,7 +361,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname, fname->disk_name.len = iname->len; return 0; } - ret = get_crypt_info(dir); + ret = load_crypt_info(dir); if (ret && ret != -EOPNOTSUPP) return ret; diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 03d2b0d..e0b3281 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -75,7 +75,7 @@ out: return res; } -static void put_crypt_info(struct fscrypt_info *ci) +static void free_crypt_info(struct fscrypt_info *ci) { if (!ci) return; @@ -85,7 +85,7 @@ static void put_crypt_info(struct fscrypt_info *ci) kmem_cache_free(fscrypt_info_cachep, ci); } -int get_crypt_info(struct inode *inode) +int load_crypt_info(struct inode *inode) { struct fscrypt_info *crypt_info; u8 full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE + @@ -112,7 +112,7 @@ retry: if (!crypt_info->ci_keyring_key || key_validate(crypt_info->ci_keyring_key) == 0) return 0; - fscrypt_put_encryption_info(inode, crypt_info); + fscrypt_unload_encryption_info(inode, crypt_info); goto retry; } @@ -224,7 +224,7 @@ got_key: memzero_explicit(raw_key, sizeof(raw_key)); if (cmpxchg(>i_crypt_info, NULL, crypt_info) != NULL) { - put_crypt_info(crypt_info); + free_crypt_info(crypt_info); goto retry; } return 0; @@ -232,12 +232,13 @@ got_key: out: if (res == -ENOKEY) res = 0; - put_crypt_info(crypt_info); + free_crypt_info(crypt_info); memzero_explicit(raw_key, sizeof(raw_key)); return res; } -void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) +void fscrypt_unload_encryption_info(struct inode *inode, + struct fscrypt_info *ci) { struct fscrypt_info *prev; @@ -250,11 +251,11 @@ void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) if (prev != ci) return; - put_crypt_info(ci); + free_crypt_info(ci); } -EXPORT_SYMBOL(fscrypt_put_encryption_info); +EXPORT_SYMBOL(fscrypt_unload_encryption_info); -int fscrypt_get_encryption_info(struct inode *inode) +int fscrypt_load_encryption_info(struct inode *inode) { struct fscrypt_info *ci = inode->i_crypt_info; @@ -263,7 +264,7 @@ int fscrypt_get_encryption_info(struct inode *inode) (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) | (1 << KEY_FLAG_REVOKED) | (1 << KEY_FLAG_DEAD) - return get_crypt_info(inode); + return load_crypt_info(inode); return 0; } -EXPORT_SYMBOL(fscrypt_get_encryption_info); +EXPORT_SYMBOL(fscrypt_load_encryption_info); diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index e1d263d..03a2f50 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -155,10 +155,10 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) /* if the child directory is not encrypted, this is always a problem */ if (!parent->i_sb->s_cop->is_encrypted(child)) return 0; - res = fscrypt_get_encryption_info(parent); + res = fscrypt_load_encryption_info(parent); if (res) return 0; - res = fscrypt_get_encryption_info(child); + res = fscrypt_load_encryption_info(child); if (res) return 0; parent_ci = parent->i_crypt_info; @@ -196,7 +196,7 @@ int
[PATCH 07/13] fscrypto: simplify building key descriptor string
Signed-off-by: Eric Biggers--- fs/crypto/keyinfo.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index cb06351..5fcee4d 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -164,13 +164,8 @@ retry: memset(raw_key, 0x42, FS_AES_256_XTS_KEY_SIZE); goto got_key; } - memcpy(full_key_descriptor, FS_KEY_DESC_PREFIX, - FS_KEY_DESC_PREFIX_SIZE); - sprintf(full_key_descriptor + FS_KEY_DESC_PREFIX_SIZE, - "%*phN", FS_KEY_DESCRIPTOR_SIZE, - ctx.master_key_descriptor); - full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE + - (2 * FS_KEY_DESCRIPTOR_SIZE)] = '\0'; + sprintf(full_key_descriptor, FS_KEY_DESC_PREFIX "%*phN", + FS_KEY_DESCRIPTOR_SIZE, ctx.master_key_descriptor); keyring_key = request_key(_type_logon, full_key_descriptor, NULL); if (IS_ERR(keyring_key)) { res = PTR_ERR(keyring_key); -- 2.7.4
[PATCH 11/13] fscrypto: restrict setting encryption policy to inode owner
On a filesystem with encryption enabled, a user could set an encryption policy on any empty directory to which they have readonly access. This is a potential security issue since such a directory might be owned by another user, and the new encryption policy may prevent that user from creating files in their own directory. Fix this by requiring inode_owner_or_capable() permission to set an encryption policy. Signed-off-by: Eric Biggers--- fs/crypto/policy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index cb5ba27..3f5c275 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -96,6 +96,9 @@ int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) { int ret = 0; + if (!inode_owner_or_capable(inode)) + return -EACCES; + if (policy->version != 0) return -EINVAL; -- 2.7.4
[PATCH 12/13] fscrypto: require write access to mount to set encryption policy
Since setting an encryption policy requires writing data to the filesystem, it should be guarded by mnt_want_write/mnt_drop_write. Otherwise, a user could cause a write to a readonly or frozen filesystem. Signed-off-by: Eric Biggers--- fs/crypto/policy.c | 11 +-- fs/f2fs/file.c | 2 +- include/linux/fscrypto.h | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 3f5c275..6a767e6 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -11,6 +11,7 @@ #include #include #include +#include static bool inode_has_encryption_context(struct inode *inode) { @@ -92,9 +93,10 @@ static int create_encryption_context_from_policy(struct inode *inode, return inode->i_sb->s_cop->set_context(inode, , sizeof(ctx), NULL); } -int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) +int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) { - int ret = 0; + struct inode *inode = file_inode(file); + int ret; if (!inode_owner_or_capable(inode)) return -EACCES; @@ -102,6 +104,10 @@ int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) if (policy->version != 0) return -EINVAL; + ret = mnt_want_write_file(file); + if (ret) + return ret; + inode_lock(inode); if (!inode_has_encryption_context(inode)) { @@ -131,6 +137,7 @@ int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) ret = -EINVAL; } inode_unlock(inode); + mnt_drop_write_file(file); return ret; } EXPORT_SYMBOL(fscrypt_set_policy); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index cf691ae..d4837280 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1542,7 +1542,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) return -EFAULT; f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); - return fscrypt_set_policy(inode, ); + return fscrypt_set_policy(filp, ); } static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h index f29dc8c..130bf23 100644 --- a/include/linux/fscrypto.h +++ b/include/linux/fscrypto.h @@ -314,7 +314,7 @@ extern void fscrypt_restore_control_page(struct page *); extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, unsigned int); /* policy.c */ -extern int fscrypt_set_policy(struct inode *, const struct fscrypt_policy *); +extern int fscrypt_set_policy(struct file *, const struct fscrypt_policy *); extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); extern bool fscrypt_has_permitted_context(struct inode *, struct inode *); extern int fscrypt_inherit_context(struct inode *, struct inode *, @@ -384,7 +384,7 @@ static inline int fscrypt_notsupp_zeroout_range(struct inode *i, pgoff_t p, } /* policy.c */ -static inline int fscrypt_notsupp_set_policy(struct inode *i, +static inline int fscrypt_notsupp_set_policy(struct file *f, const struct fscrypt_policy *p) { return -EOPNOTSUPP; -- 2.7.4
[PATCH 07/13] fscrypto: simplify building key descriptor string
Signed-off-by: Eric Biggers --- fs/crypto/keyinfo.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index cb06351..5fcee4d 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -164,13 +164,8 @@ retry: memset(raw_key, 0x42, FS_AES_256_XTS_KEY_SIZE); goto got_key; } - memcpy(full_key_descriptor, FS_KEY_DESC_PREFIX, - FS_KEY_DESC_PREFIX_SIZE); - sprintf(full_key_descriptor + FS_KEY_DESC_PREFIX_SIZE, - "%*phN", FS_KEY_DESCRIPTOR_SIZE, - ctx.master_key_descriptor); - full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE + - (2 * FS_KEY_DESCRIPTOR_SIZE)] = '\0'; + sprintf(full_key_descriptor, FS_KEY_DESC_PREFIX "%*phN", + FS_KEY_DESCRIPTOR_SIZE, ctx.master_key_descriptor); keyring_key = request_key(_type_logon, full_key_descriptor, NULL); if (IS_ERR(keyring_key)) { res = PTR_ERR(keyring_key); -- 2.7.4
[PATCH 11/13] fscrypto: restrict setting encryption policy to inode owner
On a filesystem with encryption enabled, a user could set an encryption policy on any empty directory to which they have readonly access. This is a potential security issue since such a directory might be owned by another user, and the new encryption policy may prevent that user from creating files in their own directory. Fix this by requiring inode_owner_or_capable() permission to set an encryption policy. Signed-off-by: Eric Biggers --- fs/crypto/policy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index cb5ba27..3f5c275 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -96,6 +96,9 @@ int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) { int ret = 0; + if (!inode_owner_or_capable(inode)) + return -EACCES; + if (policy->version != 0) return -EINVAL; -- 2.7.4
[PATCH 12/13] fscrypto: require write access to mount to set encryption policy
Since setting an encryption policy requires writing data to the filesystem, it should be guarded by mnt_want_write/mnt_drop_write. Otherwise, a user could cause a write to a readonly or frozen filesystem. Signed-off-by: Eric Biggers --- fs/crypto/policy.c | 11 +-- fs/f2fs/file.c | 2 +- include/linux/fscrypto.h | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 3f5c275..6a767e6 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -11,6 +11,7 @@ #include #include #include +#include static bool inode_has_encryption_context(struct inode *inode) { @@ -92,9 +93,10 @@ static int create_encryption_context_from_policy(struct inode *inode, return inode->i_sb->s_cop->set_context(inode, , sizeof(ctx), NULL); } -int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) +int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) { - int ret = 0; + struct inode *inode = file_inode(file); + int ret; if (!inode_owner_or_capable(inode)) return -EACCES; @@ -102,6 +104,10 @@ int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) if (policy->version != 0) return -EINVAL; + ret = mnt_want_write_file(file); + if (ret) + return ret; + inode_lock(inode); if (!inode_has_encryption_context(inode)) { @@ -131,6 +137,7 @@ int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) ret = -EINVAL; } inode_unlock(inode); + mnt_drop_write_file(file); return ret; } EXPORT_SYMBOL(fscrypt_set_policy); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index cf691ae..d4837280 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1542,7 +1542,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) return -EFAULT; f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); - return fscrypt_set_policy(inode, ); + return fscrypt_set_policy(filp, ); } static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h index f29dc8c..130bf23 100644 --- a/include/linux/fscrypto.h +++ b/include/linux/fscrypto.h @@ -314,7 +314,7 @@ extern void fscrypt_restore_control_page(struct page *); extern int fscrypt_zeroout_range(struct inode *, pgoff_t, sector_t, unsigned int); /* policy.c */ -extern int fscrypt_set_policy(struct inode *, const struct fscrypt_policy *); +extern int fscrypt_set_policy(struct file *, const struct fscrypt_policy *); extern int fscrypt_get_policy(struct inode *, struct fscrypt_policy *); extern bool fscrypt_has_permitted_context(struct inode *, struct inode *); extern int fscrypt_inherit_context(struct inode *, struct inode *, @@ -384,7 +384,7 @@ static inline int fscrypt_notsupp_zeroout_range(struct inode *i, pgoff_t p, } /* policy.c */ -static inline int fscrypt_notsupp_set_policy(struct inode *i, +static inline int fscrypt_notsupp_set_policy(struct file *f, const struct fscrypt_policy *p) { return -EOPNOTSUPP; -- 2.7.4
[PATCH 03/13] fscrypto: rename functions to load and unload inode encryption info
Perform the following renamings: fscrypt_get_encryption_info() => fscrypt_load_encryption_info() fscrypt_put_encryption_info() => fscrypt_unload_encryption_info() get_crypt_info => load_crypt_info() put_crypt_info() => free_crypt_info() The new names better reflect the actual behavior where the "load" function just loads the fscrypt_info into i_crypto_info; it doesn't actually return it to the caller. There is also no reference counting involved, as might be suggested by the verbs "get" and "put". Signed-off-by: Eric Biggers --- fs/crypto/fname.c| 2 +- fs/crypto/keyinfo.c | 23 --- fs/crypto/policy.c | 8 fs/f2fs/dir.c| 4 ++-- fs/f2fs/f2fs.h | 4 ++-- fs/f2fs/file.c | 8 fs/f2fs/inode.c | 2 +- fs/f2fs/namei.c | 10 +- fs/f2fs/super.c | 2 +- include/linux/fscrypto.h | 11 ++- 10 files changed, 38 insertions(+), 36 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index c3e3554..ceaa815 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -361,7 +361,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname, fname->disk_name.len = iname->len; return 0; } - ret = get_crypt_info(dir); + ret = load_crypt_info(dir); if (ret && ret != -EOPNOTSUPP) return ret; diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 03d2b0d..e0b3281 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -75,7 +75,7 @@ out: return res; } -static void put_crypt_info(struct fscrypt_info *ci) +static void free_crypt_info(struct fscrypt_info *ci) { if (!ci) return; @@ -85,7 +85,7 @@ static void put_crypt_info(struct fscrypt_info *ci) kmem_cache_free(fscrypt_info_cachep, ci); } -int get_crypt_info(struct inode *inode) +int load_crypt_info(struct inode *inode) { struct fscrypt_info *crypt_info; u8 full_key_descriptor[FS_KEY_DESC_PREFIX_SIZE + @@ -112,7 +112,7 @@ retry: if (!crypt_info->ci_keyring_key || key_validate(crypt_info->ci_keyring_key) == 0) return 0; - fscrypt_put_encryption_info(inode, crypt_info); + fscrypt_unload_encryption_info(inode, crypt_info); goto retry; } @@ -224,7 +224,7 @@ got_key: memzero_explicit(raw_key, sizeof(raw_key)); if (cmpxchg(>i_crypt_info, NULL, crypt_info) != NULL) { - put_crypt_info(crypt_info); + free_crypt_info(crypt_info); goto retry; } return 0; @@ -232,12 +232,13 @@ got_key: out: if (res == -ENOKEY) res = 0; - put_crypt_info(crypt_info); + free_crypt_info(crypt_info); memzero_explicit(raw_key, sizeof(raw_key)); return res; } -void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) +void fscrypt_unload_encryption_info(struct inode *inode, + struct fscrypt_info *ci) { struct fscrypt_info *prev; @@ -250,11 +251,11 @@ void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) if (prev != ci) return; - put_crypt_info(ci); + free_crypt_info(ci); } -EXPORT_SYMBOL(fscrypt_put_encryption_info); +EXPORT_SYMBOL(fscrypt_unload_encryption_info); -int fscrypt_get_encryption_info(struct inode *inode) +int fscrypt_load_encryption_info(struct inode *inode) { struct fscrypt_info *ci = inode->i_crypt_info; @@ -263,7 +264,7 @@ int fscrypt_get_encryption_info(struct inode *inode) (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) | (1 << KEY_FLAG_REVOKED) | (1 << KEY_FLAG_DEAD) - return get_crypt_info(inode); + return load_crypt_info(inode); return 0; } -EXPORT_SYMBOL(fscrypt_get_encryption_info); +EXPORT_SYMBOL(fscrypt_load_encryption_info); diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index e1d263d..03a2f50 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -155,10 +155,10 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) /* if the child directory is not encrypted, this is always a problem */ if (!parent->i_sb->s_cop->is_encrypted(child)) return 0; - res = fscrypt_get_encryption_info(parent); + res = fscrypt_load_encryption_info(parent); if (res) return 0; - res = fscrypt_get_encryption_info(child); + res = fscrypt_load_encryption_info(child); if (res) return 0; parent_ci = parent->i_crypt_info; @@ -196,7 +196,7 @@ int
[PATCH 13/13] fscrypto: improve error handling in fscrypt_set_policy()
In some cases, the previous code did not correctly propagate errors to the caller. Also, only one call to ->get_context() is required. Signed-off-by: Eric Biggers--- fs/crypto/policy.c | 64 +- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 6a767e6..83421fe 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -13,37 +13,17 @@ #include #include -static bool inode_has_encryption_context(struct inode *inode) -{ - if (!inode->i_sb->s_cop->get_context) - return false; - return (inode->i_sb->s_cop->get_context(inode, NULL, 0L) > 0); -} - -/* - * check whether the policy is consistent with the encryption context - * for the inode - */ -static bool is_encryption_context_consistent_with_policy(struct inode *inode, +static bool is_encryption_context_consistent_with_policy( + const struct fscrypt_context *ctx, const struct fscrypt_policy *policy) { - struct fscrypt_context ctx; - int res; - - if (!inode->i_sb->s_cop->get_context) - return false; - - res = inode->i_sb->s_cop->get_context(inode, , sizeof(ctx)); - if (res != sizeof(ctx)) - return false; - - return (memcmp(ctx.master_key_descriptor, policy->master_key_descriptor, - FS_KEY_DESCRIPTOR_SIZE) == 0 && - (ctx.flags == policy->flags) && - (ctx.contents_encryption_mode == -policy->contents_encryption_mode) && - (ctx.filenames_encryption_mode == -policy->filenames_encryption_mode)); + return memcmp(ctx->master_key_descriptor, policy->master_key_descriptor, + FS_KEY_DESCRIPTOR_SIZE) == 0 && + (ctx->flags == policy->flags) && + (ctx->contents_encryption_mode == +policy->contents_encryption_mode) && + (ctx->filenames_encryption_mode == +policy->filenames_encryption_mode); } static int create_encryption_context_from_policy(struct inode *inode, @@ -96,6 +76,7 @@ static int create_encryption_context_from_policy(struct inode *inode, int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) { struct inode *inode = file_inode(file); + struct fscrypt_context existing; int ret; if (!inode_owner_or_capable(inode)) @@ -110,7 +91,25 @@ int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) inode_lock(inode); - if (!inode_has_encryption_context(inode)) { + ret = -ENODATA; + if (inode->i_sb->s_cop->get_context) { + ret = inode->i_sb->s_cop->get_context(inode, , + sizeof(existing)); + } + if (ret != -ENODATA) { + /* An existing policy cannot be changed. However, an attempt to +* set an identical policy will succeed. */ + if (ret == sizeof(existing) && + is_encryption_context_consistent_with_policy(, +policy)) { + ret = 0; + } else if (ret >= 0 || ret == -ERANGE) { + printk(KERN_WARNING + "%s: Policy inconsistent with encryption context\n", + __func__); + ret = -EINVAL; + } + } else { /* A new policy may only be set on an empty directory or an * empty regular file. */ ret = -EINVAL; @@ -130,11 +129,6 @@ int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) ret = create_encryption_context_from_policy(inode, policy); } - } else if (!is_encryption_context_consistent_with_policy(inode, policy)) { - printk(KERN_WARNING - "%s: Policy inconsistent with encryption context\n", - __func__); - ret = -EINVAL; } inode_unlock(inode); mnt_drop_write_file(file); -- 2.7.4
[PATCH 09/13] fscrypto: make fname_encrypt() actually return length of ciphertext
This makes the return value match the comment. Previously it would actually return 0 if encryption was successful. (No callers currently care.) Signed-off-by: Eric Biggers--- fs/crypto/fname.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index e5c6959..5b10b73 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -100,12 +100,13 @@ static int fname_encrypt(struct inode *inode, } kfree(alloc_buf); skcipher_request_free(req); - if (res < 0) + if (res < 0) { printk_ratelimited(KERN_ERR "%s: Error (error code %d)\n", __func__, res); - + return res; + } oname->len = ciphertext_len; - return res; + return ciphertext_len; } /* -- 2.7.4
[PATCH 13/13] fscrypto: improve error handling in fscrypt_set_policy()
In some cases, the previous code did not correctly propagate errors to the caller. Also, only one call to ->get_context() is required. Signed-off-by: Eric Biggers --- fs/crypto/policy.c | 64 +- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 6a767e6..83421fe 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -13,37 +13,17 @@ #include #include -static bool inode_has_encryption_context(struct inode *inode) -{ - if (!inode->i_sb->s_cop->get_context) - return false; - return (inode->i_sb->s_cop->get_context(inode, NULL, 0L) > 0); -} - -/* - * check whether the policy is consistent with the encryption context - * for the inode - */ -static bool is_encryption_context_consistent_with_policy(struct inode *inode, +static bool is_encryption_context_consistent_with_policy( + const struct fscrypt_context *ctx, const struct fscrypt_policy *policy) { - struct fscrypt_context ctx; - int res; - - if (!inode->i_sb->s_cop->get_context) - return false; - - res = inode->i_sb->s_cop->get_context(inode, , sizeof(ctx)); - if (res != sizeof(ctx)) - return false; - - return (memcmp(ctx.master_key_descriptor, policy->master_key_descriptor, - FS_KEY_DESCRIPTOR_SIZE) == 0 && - (ctx.flags == policy->flags) && - (ctx.contents_encryption_mode == -policy->contents_encryption_mode) && - (ctx.filenames_encryption_mode == -policy->filenames_encryption_mode)); + return memcmp(ctx->master_key_descriptor, policy->master_key_descriptor, + FS_KEY_DESCRIPTOR_SIZE) == 0 && + (ctx->flags == policy->flags) && + (ctx->contents_encryption_mode == +policy->contents_encryption_mode) && + (ctx->filenames_encryption_mode == +policy->filenames_encryption_mode); } static int create_encryption_context_from_policy(struct inode *inode, @@ -96,6 +76,7 @@ static int create_encryption_context_from_policy(struct inode *inode, int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) { struct inode *inode = file_inode(file); + struct fscrypt_context existing; int ret; if (!inode_owner_or_capable(inode)) @@ -110,7 +91,25 @@ int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) inode_lock(inode); - if (!inode_has_encryption_context(inode)) { + ret = -ENODATA; + if (inode->i_sb->s_cop->get_context) { + ret = inode->i_sb->s_cop->get_context(inode, , + sizeof(existing)); + } + if (ret != -ENODATA) { + /* An existing policy cannot be changed. However, an attempt to +* set an identical policy will succeed. */ + if (ret == sizeof(existing) && + is_encryption_context_consistent_with_policy(, +policy)) { + ret = 0; + } else if (ret >= 0 || ret == -ERANGE) { + printk(KERN_WARNING + "%s: Policy inconsistent with encryption context\n", + __func__); + ret = -EINVAL; + } + } else { /* A new policy may only be set on an empty directory or an * empty regular file. */ ret = -EINVAL; @@ -130,11 +129,6 @@ int fscrypt_set_policy(struct file *file, const struct fscrypt_policy *policy) ret = create_encryption_context_from_policy(inode, policy); } - } else if (!is_encryption_context_consistent_with_policy(inode, policy)) { - printk(KERN_WARNING - "%s: Policy inconsistent with encryption context\n", - __func__); - ret = -EINVAL; } inode_unlock(inode); mnt_drop_write_file(file); -- 2.7.4
[PATCH 09/13] fscrypto: make fname_encrypt() actually return length of ciphertext
This makes the return value match the comment. Previously it would actually return 0 if encryption was successful. (No callers currently care.) Signed-off-by: Eric Biggers --- fs/crypto/fname.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index e5c6959..5b10b73 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -100,12 +100,13 @@ static int fname_encrypt(struct inode *inode, } kfree(alloc_buf); skcipher_request_free(req); - if (res < 0) + if (res < 0) { printk_ratelimited(KERN_ERR "%s: Error (error code %d)\n", __func__, res); - + return res; + } oname->len = ciphertext_len; - return res; + return ciphertext_len; } /* -- 2.7.4
[PATCH 08/13] fscrypto: use standard macros from kernel.h
Signed-off-by: Eric Biggers--- fs/crypto/fname.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index cd0eae8..e5c6959 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -14,11 +14,6 @@ #include #include -static u32 size_round_up(size_t size, size_t blksize) -{ - return ((size + blksize - 1) / blksize) * blksize; -} - /** * fname_crypt_complete() - The completion callback for filename encryption and * decryption @@ -61,10 +56,9 @@ static int fname_encrypt(struct inode *inode, if (iname->len <= 0 || iname->len > lim) return -EIO; - ciphertext_len = (iname->len < FS_CRYPTO_BLOCK_SIZE) ? - FS_CRYPTO_BLOCK_SIZE : iname->len; - ciphertext_len = size_round_up(ciphertext_len, padding); - ciphertext_len = (ciphertext_len > lim) ? lim : ciphertext_len; + ciphertext_len = max_t(u32, iname->len, FS_CRYPTO_BLOCK_SIZE); + ciphertext_len = round_up(ciphertext_len, padding); + ciphertext_len = min(ciphertext_len, lim); if (ciphertext_len <= sizeof(buf)) { workbuf = buf; @@ -235,9 +229,8 @@ u32 fscrypt_fname_encrypted_size(struct inode *inode, u32 ilen) if (ci) padding = 4 << (ci->ci_flags & FS_POLICY_FLAGS_PAD_MASK); - if (ilen < FS_CRYPTO_BLOCK_SIZE) - ilen = FS_CRYPTO_BLOCK_SIZE; - return size_round_up(ilen, padding); + ilen = max_t(u32, ilen, FS_CRYPTO_BLOCK_SIZE); + return round_up(ilen, padding); } EXPORT_SYMBOL(fscrypt_fname_encrypted_size); -- 2.7.4
[PATCH 08/13] fscrypto: use standard macros from kernel.h
Signed-off-by: Eric Biggers --- fs/crypto/fname.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index cd0eae8..e5c6959 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -14,11 +14,6 @@ #include #include -static u32 size_round_up(size_t size, size_t blksize) -{ - return ((size + blksize - 1) / blksize) * blksize; -} - /** * fname_crypt_complete() - The completion callback for filename encryption and * decryption @@ -61,10 +56,9 @@ static int fname_encrypt(struct inode *inode, if (iname->len <= 0 || iname->len > lim) return -EIO; - ciphertext_len = (iname->len < FS_CRYPTO_BLOCK_SIZE) ? - FS_CRYPTO_BLOCK_SIZE : iname->len; - ciphertext_len = size_round_up(ciphertext_len, padding); - ciphertext_len = (ciphertext_len > lim) ? lim : ciphertext_len; + ciphertext_len = max_t(u32, iname->len, FS_CRYPTO_BLOCK_SIZE); + ciphertext_len = round_up(ciphertext_len, padding); + ciphertext_len = min(ciphertext_len, lim); if (ciphertext_len <= sizeof(buf)) { workbuf = buf; @@ -235,9 +229,8 @@ u32 fscrypt_fname_encrypted_size(struct inode *inode, u32 ilen) if (ci) padding = 4 << (ci->ci_flags & FS_POLICY_FLAGS_PAD_MASK); - if (ilen < FS_CRYPTO_BLOCK_SIZE) - ilen = FS_CRYPTO_BLOCK_SIZE; - return size_round_up(ilen, padding); + ilen = max_t(u32, ilen, FS_CRYPTO_BLOCK_SIZE); + return round_up(ilen, padding); } EXPORT_SYMBOL(fscrypt_fname_encrypted_size); -- 2.7.4
[PATCH 10/13] fscrypto: restrict setting new policy to empty files and directories only
On f2fs, a user could create a regular file of small positive size and issue FS_IOC_SET_ENCRYPTION_POLICY to set its encryption policy. However, this did not behave as expected because the existing data was not actually encrypted by the ioctl. Fix this by only permitting an encryption policy to be created for empty regular files and directories. For a correct solution, it is necessary to conduct the operation under the inode lock; otherwise the inode's size might be changed concurrently. Signed-off-by: Eric Biggers--- fs/crypto/policy.c | 42 ++ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 93244b5..cb5ba27 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -94,23 +94,41 @@ static int create_encryption_context_from_policy(struct inode *inode, int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) { + int ret = 0; + if (policy->version != 0) return -EINVAL; + inode_lock(inode); + if (!inode_has_encryption_context(inode)) { - if (!inode->i_sb->s_cop->empty_dir) - return -EOPNOTSUPP; - if (!inode->i_sb->s_cop->empty_dir(inode)) - return -ENOTEMPTY; - return create_encryption_context_from_policy(inode, policy); + /* A new policy may only be set on an empty directory or an +* empty regular file. */ + ret = -EINVAL; + if (S_ISDIR(inode->i_mode)) { + if (!inode->i_sb->s_cop->empty_dir) + ret = -EOPNOTSUPP; + else if (inode->i_sb->s_cop->empty_dir(inode)) + ret = 0; + else + ret = -ENOTEMPTY; + } else if (S_ISREG(inode->i_mode)) { + ret = -ENOTEMPTY; + if (inode->i_size == 0) + ret = 0; + } + if (!ret) { + ret = create_encryption_context_from_policy(inode, + policy); + } + } else if (!is_encryption_context_consistent_with_policy(inode, policy)) { + printk(KERN_WARNING + "%s: Policy inconsistent with encryption context\n", + __func__); + ret = -EINVAL; } - - if (is_encryption_context_consistent_with_policy(inode, policy)) - return 0; - - printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n", - __func__); - return -EINVAL; + inode_unlock(inode); + return ret; } EXPORT_SYMBOL(fscrypt_set_policy); -- 2.7.4
[PATCH 10/13] fscrypto: restrict setting new policy to empty files and directories only
On f2fs, a user could create a regular file of small positive size and issue FS_IOC_SET_ENCRYPTION_POLICY to set its encryption policy. However, this did not behave as expected because the existing data was not actually encrypted by the ioctl. Fix this by only permitting an encryption policy to be created for empty regular files and directories. For a correct solution, it is necessary to conduct the operation under the inode lock; otherwise the inode's size might be changed concurrently. Signed-off-by: Eric Biggers --- fs/crypto/policy.c | 42 ++ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 93244b5..cb5ba27 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -94,23 +94,41 @@ static int create_encryption_context_from_policy(struct inode *inode, int fscrypt_set_policy(struct inode *inode, const struct fscrypt_policy *policy) { + int ret = 0; + if (policy->version != 0) return -EINVAL; + inode_lock(inode); + if (!inode_has_encryption_context(inode)) { - if (!inode->i_sb->s_cop->empty_dir) - return -EOPNOTSUPP; - if (!inode->i_sb->s_cop->empty_dir(inode)) - return -ENOTEMPTY; - return create_encryption_context_from_policy(inode, policy); + /* A new policy may only be set on an empty directory or an +* empty regular file. */ + ret = -EINVAL; + if (S_ISDIR(inode->i_mode)) { + if (!inode->i_sb->s_cop->empty_dir) + ret = -EOPNOTSUPP; + else if (inode->i_sb->s_cop->empty_dir(inode)) + ret = 0; + else + ret = -ENOTEMPTY; + } else if (S_ISREG(inode->i_mode)) { + ret = -ENOTEMPTY; + if (inode->i_size == 0) + ret = 0; + } + if (!ret) { + ret = create_encryption_context_from_policy(inode, + policy); + } + } else if (!is_encryption_context_consistent_with_policy(inode, policy)) { + printk(KERN_WARNING + "%s: Policy inconsistent with encryption context\n", + __func__); + ret = -EINVAL; } - - if (is_encryption_context_consistent_with_policy(inode, policy)) - return 0; - - printk(KERN_WARNING "%s: Policy inconsistent with encryption context\n", - __func__); - return -EINVAL; + inode_unlock(inode); + return ret; } EXPORT_SYMBOL(fscrypt_set_policy); -- 2.7.4
RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Saturday, April 2, 2016 6:48 PM > To: KY Srinivasan> Cc: o...@aepfle.de; jasow...@redhat.com; linux-kernel@vger.kernel.org; > a...@canonical.com; de...@linuxdriverproject.org > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > management. > > On Sat, Apr 02, 2016 at 11:46:21PM +, KY Srinivasan wrote: > > > > > > > -Original Message- > > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > > Sent: Saturday, April 2, 2016 3:23 PM > > > To: KY Srinivasan > > > Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; > > > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com; > > > jasow...@redhat.com > > > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > > > management. > > > > > > On Sat, Apr 02, 2016 at 11:10:38AM -0700, K. Y. Srinivasan wrote: > > > > Cleanup and mmio management. Also included is a patch > > > > to fix an issue in KVP. > > > > > > So these all are for 4.7-rc1? > > > > Jake's PCI driver made it into 4.6 and some of the patches in this series > > fix > issues in the Hyper-V > > PCI pass-through driver. Is it possible for this series to go into 4.6. If > > not, > 4.7-rc1 is fine. > > Even patch 1? Please be specific where you want patches to be merged > to. Patch 1 can go into 4.7. If Jake's patches can go into 4.6, that would be good. Do you want me to resend the patches that clearly indicate where the patches need to be merged. Thank you for your patience. K. Y > > greg k-h
RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Saturday, April 2, 2016 6:48 PM > To: KY Srinivasan > Cc: o...@aepfle.de; jasow...@redhat.com; linux-kernel@vger.kernel.org; > a...@canonical.com; de...@linuxdriverproject.org > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > management. > > On Sat, Apr 02, 2016 at 11:46:21PM +, KY Srinivasan wrote: > > > > > > > -Original Message- > > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > > Sent: Saturday, April 2, 2016 3:23 PM > > > To: KY Srinivasan > > > Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; > > > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com; > > > jasow...@redhat.com > > > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > > > management. > > > > > > On Sat, Apr 02, 2016 at 11:10:38AM -0700, K. Y. Srinivasan wrote: > > > > Cleanup and mmio management. Also included is a patch > > > > to fix an issue in KVP. > > > > > > So these all are for 4.7-rc1? > > > > Jake's PCI driver made it into 4.6 and some of the patches in this series > > fix > issues in the Hyper-V > > PCI pass-through driver. Is it possible for this series to go into 4.6. If > > not, > 4.7-rc1 is fine. > > Even patch 1? Please be specific where you want patches to be merged > to. Patch 1 can go into 4.7. If Jake's patches can go into 4.6, that would be good. Do you want me to resend the patches that clearly indicate where the patches need to be merged. Thank you for your patience. K. Y > > greg k-h
include/linux/unaligned/access_ok.h:7:19: error: redefinition of 'get_unaligned_le16'
Hi Clément, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: dece45855a8b0d1dcf48eb01d0822070ded6a4c8 NFC: nxp-nci: Add support for NXP NCI chips date: 1 year ago config: ia64-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout dece45855a8b0d1dcf48eb01d0822070ded6a4c8 # save the attached .config to linux build tree make.cross ARCH=ia64 All errors (new ones prefixed by >>): In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:7:19: error: redefinition of >> 'get_unaligned_le16' static inline u16 get_unaligned_le16(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:4:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/le_struct.h:6:19: note: previous definition of 'get_unaligned_le16' was here static inline u16 get_unaligned_le16(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:12:19: error: redefinition of >> 'get_unaligned_le32' static inline u32 get_unaligned_le32(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:4:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/le_struct.h:11:19: note: previous definition of 'get_unaligned_le32' was here static inline u32 get_unaligned_le32(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:17:19: error: redefinition of >> 'get_unaligned_le64' static inline u64 get_unaligned_le64(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:4:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/le_struct.h:16:19: note: previous definition of 'get_unaligned_le64' was here static inline u64 get_unaligned_le64(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:22:19: error: redefinition of >> 'get_unaligned_be16' static inline u16 get_unaligned_be16(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/be_byteshift.h:40:19: note: previous definition of 'get_unaligned_be16' was here static inline u16 get_unaligned_be16(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:27:19: error: redefinition of >> 'get_unaligned_be32' static inline u32 get_unaligned_be32(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/be_byteshift.h:45:19: note: previous definition of 'get_unaligned_be32' was here static inline u32 get_unaligned_be32(const void *p)
include/linux/unaligned/access_ok.h:7:19: error: redefinition of 'get_unaligned_le16'
Hi Clément, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: dece45855a8b0d1dcf48eb01d0822070ded6a4c8 NFC: nxp-nci: Add support for NXP NCI chips date: 1 year ago config: ia64-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout dece45855a8b0d1dcf48eb01d0822070ded6a4c8 # save the attached .config to linux build tree make.cross ARCH=ia64 All errors (new ones prefixed by >>): In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:7:19: error: redefinition of >> 'get_unaligned_le16' static inline u16 get_unaligned_le16(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:4:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/le_struct.h:6:19: note: previous definition of 'get_unaligned_le16' was here static inline u16 get_unaligned_le16(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:12:19: error: redefinition of >> 'get_unaligned_le32' static inline u32 get_unaligned_le32(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:4:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/le_struct.h:11:19: note: previous definition of 'get_unaligned_le32' was here static inline u32 get_unaligned_le32(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:17:19: error: redefinition of >> 'get_unaligned_le64' static inline u64 get_unaligned_le64(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:4:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/le_struct.h:16:19: note: previous definition of 'get_unaligned_le64' was here static inline u64 get_unaligned_le64(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:22:19: error: redefinition of >> 'get_unaligned_be16' static inline u16 get_unaligned_be16(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/be_byteshift.h:40:19: note: previous definition of 'get_unaligned_be16' was here static inline u16 get_unaligned_be16(const void *p) ^ In file included from drivers/nfc/nxp-nci/firmware.c:27:0: >> include/linux/unaligned/access_ok.h:27:19: error: redefinition of >> 'get_unaligned_be32' static inline u32 get_unaligned_be32(const void *p) ^ In file included from arch/ia64/include/asm/unaligned.h:5:0, from arch/ia64/include/asm/io.h:22, from arch/ia64/include/asm/smp.h:20, from include/linux/smp.h:59, from include/linux/topology.h:33, from include/linux/gfp.h:8, from include/linux/firmware.h:6, from drivers/nfc/nxp-nci/firmware.c:25: include/linux/unaligned/be_byteshift.h:45:19: note: previous definition of 'get_unaligned_be32' was here static inline u32 get_unaligned_be32(const void *p)
Re: [PATCH 1/3 v2] drm/i2c/adv7511: Add audio support
Hi Jose, [auto build test ERROR on drm/drm-next] [also build test ERROR on v4.6-rc1 next-20160401] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Jose-Abreu/Add-I2S-ADV7511-audio-support-for-ARC-AXS10x-boards/20160328-224040 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-randconfig-s5-04031201 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/built-in.o: In function `adv7511_audio_init': >> (.text+0x1c608b): undefined reference to `snd_soc_register_codec' drivers/built-in.o: In function `adv7511_audio_exit': >> (.text+0x1c6096): undefined reference to `snd_soc_unregister_codec' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH 1/3 v2] drm/i2c/adv7511: Add audio support
Hi Jose, [auto build test ERROR on drm/drm-next] [also build test ERROR on v4.6-rc1 next-20160401] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Jose-Abreu/Add-I2S-ADV7511-audio-support-for-ARC-AXS10x-boards/20160328-224040 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-randconfig-s5-04031201 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/built-in.o: In function `adv7511_audio_init': >> (.text+0x1c608b): undefined reference to `snd_soc_register_codec' drivers/built-in.o: In function `adv7511_audio_exit': >> (.text+0x1c6096): undefined reference to `snd_soc_unregister_codec' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
drivers/infiniband/hw/mlx5/main.c:2357:31: error: 'mlx5_ib_get_vf_config' undeclared
Hi Eli, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: eff901d30e6cebd940072637f112ce4d0090ac12 IB/mlx5: Implement callbacks for manipulating VFs date: 12 days ago config: x86_64-randconfig-n0-04031158 (attached as .config) reproduce: git checkout eff901d30e6cebd940072637f112ce4d0090ac12 # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/infiniband/hw/mlx5/main.c: In function 'mlx5_ib_add': >> drivers/infiniband/hw/mlx5/main.c:2357:31: error: 'mlx5_ib_get_vf_config' >> undeclared (first use in this function) dev->ib_dev.get_vf_config = mlx5_ib_get_vf_config; ^ drivers/infiniband/hw/mlx5/main.c:2357:31: note: each undeclared identifier is reported only once for each function it appears in >> drivers/infiniband/hw/mlx5/main.c:2358:35: error: >> 'mlx5_ib_set_vf_link_state' undeclared (first use in this function) dev->ib_dev.set_vf_link_state = mlx5_ib_set_vf_link_state; ^ >> drivers/infiniband/hw/mlx5/main.c:2359:30: error: 'mlx5_ib_get_vf_stats' >> undeclared (first use in this function) dev->ib_dev.get_vf_stats = mlx5_ib_get_vf_stats; ^ >> drivers/infiniband/hw/mlx5/main.c:2360:30: error: 'mlx5_ib_set_vf_guid' >> undeclared (first use in this function) dev->ib_dev.set_vf_guid = mlx5_ib_set_vf_guid; ^ vim +/mlx5_ib_get_vf_config +2357 drivers/infiniband/hw/mlx5/main.c 2351 dev->ib_dev.process_mad = mlx5_ib_process_mad; 2352 dev->ib_dev.alloc_mr= mlx5_ib_alloc_mr; 2353 dev->ib_dev.map_mr_sg = mlx5_ib_map_mr_sg; 2354 dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; 2355 dev->ib_dev.get_port_immutable = mlx5_port_immutable; 2356 if (mlx5_core_is_pf(mdev)) { > 2357 dev->ib_dev.get_vf_config = mlx5_ib_get_vf_config; > 2358 dev->ib_dev.set_vf_link_state = > mlx5_ib_set_vf_link_state; > 2359 dev->ib_dev.get_vf_stats= mlx5_ib_get_vf_stats; > 2360 dev->ib_dev.set_vf_guid = mlx5_ib_set_vf_guid; 2361 } 2362 2363 mlx5_ib_internal_fill_odp_caps(dev); --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
drivers/infiniband/hw/mlx5/main.c:2357:31: error: 'mlx5_ib_get_vf_config' undeclared
Hi Eli, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: eff901d30e6cebd940072637f112ce4d0090ac12 IB/mlx5: Implement callbacks for manipulating VFs date: 12 days ago config: x86_64-randconfig-n0-04031158 (attached as .config) reproduce: git checkout eff901d30e6cebd940072637f112ce4d0090ac12 # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/infiniband/hw/mlx5/main.c: In function 'mlx5_ib_add': >> drivers/infiniband/hw/mlx5/main.c:2357:31: error: 'mlx5_ib_get_vf_config' >> undeclared (first use in this function) dev->ib_dev.get_vf_config = mlx5_ib_get_vf_config; ^ drivers/infiniband/hw/mlx5/main.c:2357:31: note: each undeclared identifier is reported only once for each function it appears in >> drivers/infiniband/hw/mlx5/main.c:2358:35: error: >> 'mlx5_ib_set_vf_link_state' undeclared (first use in this function) dev->ib_dev.set_vf_link_state = mlx5_ib_set_vf_link_state; ^ >> drivers/infiniband/hw/mlx5/main.c:2359:30: error: 'mlx5_ib_get_vf_stats' >> undeclared (first use in this function) dev->ib_dev.get_vf_stats = mlx5_ib_get_vf_stats; ^ >> drivers/infiniband/hw/mlx5/main.c:2360:30: error: 'mlx5_ib_set_vf_guid' >> undeclared (first use in this function) dev->ib_dev.set_vf_guid = mlx5_ib_set_vf_guid; ^ vim +/mlx5_ib_get_vf_config +2357 drivers/infiniband/hw/mlx5/main.c 2351 dev->ib_dev.process_mad = mlx5_ib_process_mad; 2352 dev->ib_dev.alloc_mr= mlx5_ib_alloc_mr; 2353 dev->ib_dev.map_mr_sg = mlx5_ib_map_mr_sg; 2354 dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; 2355 dev->ib_dev.get_port_immutable = mlx5_port_immutable; 2356 if (mlx5_core_is_pf(mdev)) { > 2357 dev->ib_dev.get_vf_config = mlx5_ib_get_vf_config; > 2358 dev->ib_dev.set_vf_link_state = > mlx5_ib_set_vf_link_state; > 2359 dev->ib_dev.get_vf_stats= mlx5_ib_get_vf_stats; > 2360 dev->ib_dev.set_vf_guid = mlx5_ib_set_vf_guid; 2361 } 2362 2363 mlx5_ib_internal_fill_odp_caps(dev); --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH v14 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
This patch adds drm_bridge driver for parade DSI to eDP bridge chip. Signed-off-by: Jitao ShiReviewed-by: Daniel Kurtz --- Changes since v13: - add const on data, ps8640_write_bytes(struct i2c_client *client, const u8 *data, u16 data_len) - fix PAGE2_SW_REST tyro. - move the buf[3] init to entrance of the function. Changes since v12: - fix hw_chip_id build warning Changes since v11: - Remove depends on I2C, add DRM depends - Reuse ps8640_write_bytes() in ps8640_write_byte() - Use timer check for polling like the routines in - Fix no drm_connector_unregister/drm_connector_cleanup when ps8640_bridge_attach fail - Check the ps8640 hardware id in ps8640_validate_firmware - Remove fw_version check - Move ps8640_validate_firmware before ps8640_enter_bl - Add ddc_i2c unregister when probe fail and ps8640_remove --- drivers/gpu/drm/bridge/Kconfig | 12 + drivers/gpu/drm/bridge/Makefile|1 + drivers/gpu/drm/bridge/parade-ps8640.c | 1066 3 files changed, 1079 insertions(+) create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 27e2022..be6084e 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -40,4 +40,16 @@ config DRM_PARADE_PS8622 ---help--- Parade eDP-LVDS bridge chip driver. +config DRM_PARADE_PS8640 + tristate "Parade PS8640 MIPI DSI to eDP Converter" + depends on DRM + depends on OF + select DRM_KMS_HELPER + select DRM_MIPI_DSI + select DRM_PANEL + ---help--- + Choose this option if you have PS8640 for display + The PS8640 is a high-performance and low-power + MIPI DSI to eDP converter + endmenu diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index f13c33d..fbe38dc 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c new file mode 100644 index 000..87f8bc7 --- /dev/null +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -0,0 +1,1066 @@ +/* + * Copyright (c) 2014 MediaTek Inc. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define PAGE2_SPI_CFG3 0x82 +#define I2C_TO_SPI_RESET 0x20 +#define PAGE2_ROMADD_BYTE1 0x8e +#define PAGE2_ROMADD_BYTE2 0x8f +#define PAGE2_SWSPI_WDATA 0x90 +#define PAGE2_SWSPI_RDATA 0x91 +#define PAGE2_SWSPI_LEN0x92 +#define PAGE2_SWSPI_CTL0x93 +#define TRIGGER_NO_READBACK0x05 +#define TRIGGER_READBACK 0x01 +#define PAGE2_SPI_STATUS 0x9e +#define PAGE2_GPIO_L 0xa6 +#define PAGE2_GPIO_H 0xa7 +#define PS_GPIO9 BIT(1) +#define PAGE2_IROM_CTRL0xb0 +#define IROM_ENABLE0xc0 +#define IROM_DISABLE 0x80 +#define PAGE2_SW_RESET 0xbc +#define SPI_SW_RESET BIT(7) +#define MPU_SW_RESET BIT(6) +#define PAGE2_ENCTLSPI_WR 0xda +#define PAGE2_I2C_BYPASS 0xea +#define I2C_BYPASS_EN 0xd0 +#define PAGE3_SET_ADD 0xfe +#define PAGE3_SET_VAL 0xff +#define VDO_CTL_ADD0x13 +#define VDO_DIS0x18 +#define VDO_EN 0x1c +#define PAGE4_REV_L0xf0 +#define PAGE4_REV_H0xf1 +#define PAGE4_CHIP_L 0xf2 +#define PAGE4_CHIP_H 0xf3 + +/* Firmware */ +#define SPI_MAX_RETRY_CNT 8 +#define PS_FW_NAME "ps864x_fw.bin" + +#define FW_CHIP_ID_OFFSET 0 +#define FW_VERSION_OFFSET 2 +#define EDID_I2C_ADDR 0x50 + +#define WRITE_STATUS_REG_CMD 0x01 +#define READ_STATUS_REG_CMD0x05 +#define BUSY BIT(0) +#define CLEAR_ALL_PROTECT 0x00 +#define BLK_PROTECT_BITS 0x0c +#define STATUS_REG_PROTECT BIT(7) +#define WRITE_ENABLE_CMD 0x06 +#define CHIP_ERASE_CMD 0xc7 + +#define bridge_to_ps8640(e)
[PATCH v14 1/2] Documentation: bridge: Add documentation for ps8640 DT properties
Add documentation for DT properties supported by ps8640 DSI-eDP converter. Signed-off-by: Jitao ShiAcked-by: Rob Herring Reviewed-by: Philipp Zabel --- Changes since v13: - No change --- .../devicetree/bindings/display/bridge/ps8640.txt | 43 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/ps8640.txt diff --git a/Documentation/devicetree/bindings/display/bridge/ps8640.txt b/Documentation/devicetree/bindings/display/bridge/ps8640.txt new file mode 100644 index 000..022b33f --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/ps8640.txt @@ -0,0 +1,43 @@ +ps8640-bridge bindings + +Required properties: + - compatible: "parade,ps8640" + - reg: first page address of the bridge. + - sleep-gpios: OF device-tree gpio specification for PD pin. + - reset-gpios: OF device-tree gpio specification for reset pin. + - mode-sel-gpios: OF device-tree gpio specification for mode-sel pin. + - vdd12-supply: OF device-tree regulator specification for 1.2V power. + - vdd33-supply: OF device-tree regulator specification for 3.3V power. + - ports: The device node can contain video interface port nodes per +the video-interfaces bind[1]. For port@0,set the reg = <0> as +ps8640 dsi in and port@1,set the reg = <1> as ps8640 eDP out. + +[1]: Documentation/devicetree/bindings/media/video-interfaces.txt + +Example: + edp-bridge@18 { + compatible = "parade,ps8640"; + reg = <0x18>; + sleep-gpios = < 116 GPIO_ACTIVE_LOW>; + reset-gpios = < 115 GPIO_ACTIVE_LOW>; + mode-sel-gpios = < 92 GPIO_ACTIVE_HIGH>; + vdd12-supply = <_fixed_1v2>; + vdd33-supply = <_vgp2_reg>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + ps8640_in: endpoint { + remote-endpoint = <_out>; + }; + }; + port@1 { + reg = <1>; + ps8640_out: endpoint { + remote-endpoint = <_in>; + }; + }; + }; + }; -- 1.7.9.5
[PATCH v14 1/2] Documentation: bridge: Add documentation for ps8640 DT properties
Add documentation for DT properties supported by ps8640 DSI-eDP converter. Signed-off-by: Jitao Shi Acked-by: Rob Herring Reviewed-by: Philipp Zabel --- Changes since v13: - No change --- .../devicetree/bindings/display/bridge/ps8640.txt | 43 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/ps8640.txt diff --git a/Documentation/devicetree/bindings/display/bridge/ps8640.txt b/Documentation/devicetree/bindings/display/bridge/ps8640.txt new file mode 100644 index 000..022b33f --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/ps8640.txt @@ -0,0 +1,43 @@ +ps8640-bridge bindings + +Required properties: + - compatible: "parade,ps8640" + - reg: first page address of the bridge. + - sleep-gpios: OF device-tree gpio specification for PD pin. + - reset-gpios: OF device-tree gpio specification for reset pin. + - mode-sel-gpios: OF device-tree gpio specification for mode-sel pin. + - vdd12-supply: OF device-tree regulator specification for 1.2V power. + - vdd33-supply: OF device-tree regulator specification for 3.3V power. + - ports: The device node can contain video interface port nodes per +the video-interfaces bind[1]. For port@0,set the reg = <0> as +ps8640 dsi in and port@1,set the reg = <1> as ps8640 eDP out. + +[1]: Documentation/devicetree/bindings/media/video-interfaces.txt + +Example: + edp-bridge@18 { + compatible = "parade,ps8640"; + reg = <0x18>; + sleep-gpios = < 116 GPIO_ACTIVE_LOW>; + reset-gpios = < 115 GPIO_ACTIVE_LOW>; + mode-sel-gpios = < 92 GPIO_ACTIVE_HIGH>; + vdd12-supply = <_fixed_1v2>; + vdd33-supply = <_vgp2_reg>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + ps8640_in: endpoint { + remote-endpoint = <_out>; + }; + }; + port@1 { + reg = <1>; + ps8640_out: endpoint { + remote-endpoint = <_in>; + }; + }; + }; + }; -- 1.7.9.5
[PATCH v14 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
This patch adds drm_bridge driver for parade DSI to eDP bridge chip. Signed-off-by: Jitao Shi Reviewed-by: Daniel Kurtz --- Changes since v13: - add const on data, ps8640_write_bytes(struct i2c_client *client, const u8 *data, u16 data_len) - fix PAGE2_SW_REST tyro. - move the buf[3] init to entrance of the function. Changes since v12: - fix hw_chip_id build warning Changes since v11: - Remove depends on I2C, add DRM depends - Reuse ps8640_write_bytes() in ps8640_write_byte() - Use timer check for polling like the routines in - Fix no drm_connector_unregister/drm_connector_cleanup when ps8640_bridge_attach fail - Check the ps8640 hardware id in ps8640_validate_firmware - Remove fw_version check - Move ps8640_validate_firmware before ps8640_enter_bl - Add ddc_i2c unregister when probe fail and ps8640_remove --- drivers/gpu/drm/bridge/Kconfig | 12 + drivers/gpu/drm/bridge/Makefile|1 + drivers/gpu/drm/bridge/parade-ps8640.c | 1066 3 files changed, 1079 insertions(+) create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 27e2022..be6084e 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -40,4 +40,16 @@ config DRM_PARADE_PS8622 ---help--- Parade eDP-LVDS bridge chip driver. +config DRM_PARADE_PS8640 + tristate "Parade PS8640 MIPI DSI to eDP Converter" + depends on DRM + depends on OF + select DRM_KMS_HELPER + select DRM_MIPI_DSI + select DRM_PANEL + ---help--- + Choose this option if you have PS8640 for display + The PS8640 is a high-performance and low-power + MIPI DSI to eDP converter + endmenu diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index f13c33d..fbe38dc 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c new file mode 100644 index 000..87f8bc7 --- /dev/null +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -0,0 +1,1066 @@ +/* + * Copyright (c) 2014 MediaTek Inc. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define PAGE2_SPI_CFG3 0x82 +#define I2C_TO_SPI_RESET 0x20 +#define PAGE2_ROMADD_BYTE1 0x8e +#define PAGE2_ROMADD_BYTE2 0x8f +#define PAGE2_SWSPI_WDATA 0x90 +#define PAGE2_SWSPI_RDATA 0x91 +#define PAGE2_SWSPI_LEN0x92 +#define PAGE2_SWSPI_CTL0x93 +#define TRIGGER_NO_READBACK0x05 +#define TRIGGER_READBACK 0x01 +#define PAGE2_SPI_STATUS 0x9e +#define PAGE2_GPIO_L 0xa6 +#define PAGE2_GPIO_H 0xa7 +#define PS_GPIO9 BIT(1) +#define PAGE2_IROM_CTRL0xb0 +#define IROM_ENABLE0xc0 +#define IROM_DISABLE 0x80 +#define PAGE2_SW_RESET 0xbc +#define SPI_SW_RESET BIT(7) +#define MPU_SW_RESET BIT(6) +#define PAGE2_ENCTLSPI_WR 0xda +#define PAGE2_I2C_BYPASS 0xea +#define I2C_BYPASS_EN 0xd0 +#define PAGE3_SET_ADD 0xfe +#define PAGE3_SET_VAL 0xff +#define VDO_CTL_ADD0x13 +#define VDO_DIS0x18 +#define VDO_EN 0x1c +#define PAGE4_REV_L0xf0 +#define PAGE4_REV_H0xf1 +#define PAGE4_CHIP_L 0xf2 +#define PAGE4_CHIP_H 0xf3 + +/* Firmware */ +#define SPI_MAX_RETRY_CNT 8 +#define PS_FW_NAME "ps864x_fw.bin" + +#define FW_CHIP_ID_OFFSET 0 +#define FW_VERSION_OFFSET 2 +#define EDID_I2C_ADDR 0x50 + +#define WRITE_STATUS_REG_CMD 0x01 +#define READ_STATUS_REG_CMD0x05 +#define BUSY BIT(0) +#define CLEAR_ALL_PROTECT 0x00 +#define BLK_PROTECT_BITS 0x0c +#define STATUS_REG_PROTECT BIT(7) +#define WRITE_ENABLE_CMD 0x06 +#define CHIP_ERASE_CMD 0xc7 + +#define bridge_to_ps8640(e)container_of(e, struct ps8640, bridge) +#define
drivers/mfd/syscon.c:67:9: error: implicit declaration of function 'ioremap'
Hi Philipp, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: ca668f0edfae65438c3f0a3ad5d3e59e3515915f mfd: syscon: Set regmap max_register in of_syscon_register date: 3 weeks ago config: um-allyesconfig (attached as .config) reproduce: git checkout ca668f0edfae65438c3f0a3ad5d3e59e3515915f # save the attached .config to linux build tree make ARCH=um All errors (new ones prefixed by >>): drivers/mfd/syscon.c: In function 'of_syscon_register': >> drivers/mfd/syscon.c:67:9: error: implicit declaration of function 'ioremap' >> [-Werror=implicit-function-declaration] base = ioremap(res.start, resource_size()); ^ drivers/mfd/syscon.c:67:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion] base = ioremap(res.start, resource_size()); ^ drivers/mfd/syscon.c:109:2: error: implicit declaration of function 'iounmap' [-Werror=implicit-function-declaration] iounmap(base); ^ cc1: some warnings being treated as errors vim +/ioremap +67 drivers/mfd/syscon.c 61 62 if (of_address_to_resource(np, 0, )) { 63 ret = -ENOMEM; 64 goto err_map; 65 } 66 > 67 base = ioremap(res.start, resource_size()); 68 if (!base) { 69 ret = -ENOMEM; 70 goto err_map; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
drivers/mfd/syscon.c:67:9: error: implicit declaration of function 'ioremap'
Hi Philipp, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: ca668f0edfae65438c3f0a3ad5d3e59e3515915f mfd: syscon: Set regmap max_register in of_syscon_register date: 3 weeks ago config: um-allyesconfig (attached as .config) reproduce: git checkout ca668f0edfae65438c3f0a3ad5d3e59e3515915f # save the attached .config to linux build tree make ARCH=um All errors (new ones prefixed by >>): drivers/mfd/syscon.c: In function 'of_syscon_register': >> drivers/mfd/syscon.c:67:9: error: implicit declaration of function 'ioremap' >> [-Werror=implicit-function-declaration] base = ioremap(res.start, resource_size()); ^ drivers/mfd/syscon.c:67:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion] base = ioremap(res.start, resource_size()); ^ drivers/mfd/syscon.c:109:2: error: implicit declaration of function 'iounmap' [-Werror=implicit-function-declaration] iounmap(base); ^ cc1: some warnings being treated as errors vim +/ioremap +67 drivers/mfd/syscon.c 61 62 if (of_address_to_resource(np, 0, )) { 63 ret = -ENOMEM; 64 goto err_map; 65 } 66 > 67 base = ioremap(res.start, resource_size()); 68 if (!base) { 69 ret = -ENOMEM; 70 goto err_map; --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
drivers/mfd/syscon.c:89:2: error: implicit declaration of function 'iounmap'
Hi Rob, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: 0166dc11be911213e0b1b764488c671be4c48cf3 of: make CONFIG_OF user selectable date: 10 months ago config: um-allyesconfig (attached as .config) reproduce: git checkout 0166dc11be911213e0b1b764488c671be4c48cf3 # save the attached .config to linux build tree make ARCH=um All errors (new ones prefixed by >>): drivers/mfd/syscon.c: In function 'of_syscon_register': >> drivers/mfd/syscon.c:89:2: error: implicit declaration of function 'iounmap' >> [-Werror=implicit-function-declaration] iounmap(base); ^ cc1: some warnings being treated as errors vim +/iounmap +89 drivers/mfd/syscon.c bdb0066d Pankaj Dubey 2014-09-30 73if (IS_ERR(regmap)) { bdb0066d Pankaj Dubey 2014-09-30 74pr_err("regmap init failed\n"); bdb0066d Pankaj Dubey 2014-09-30 75ret = PTR_ERR(regmap); bdb0066d Pankaj Dubey 2014-09-30 76goto err_regmap; bdb0066d Pankaj Dubey 2014-09-30 77} bdb0066d Pankaj Dubey 2014-09-30 78 bdb0066d Pankaj Dubey 2014-09-30 79syscon->regmap = regmap; bdb0066d Pankaj Dubey 2014-09-30 80syscon->np = np; bdb0066d Pankaj Dubey 2014-09-30 81 bdb0066d Pankaj Dubey 2014-09-30 82spin_lock(_list_slock); bdb0066d Pankaj Dubey 2014-09-30 83list_add_tail(>list, _list); bdb0066d Pankaj Dubey 2014-09-30 84spin_unlock(_list_slock); 87d68730 Dong Aisheng 2012-09-05 85 bdb0066d Pankaj Dubey 2014-09-30 86return syscon; bdb0066d Pankaj Dubey 2014-09-30 87 bdb0066d Pankaj Dubey 2014-09-30 88 err_regmap: bdb0066d Pankaj Dubey 2014-09-30 @89iounmap(base); bdb0066d Pankaj Dubey 2014-09-30 90 err_map: bdb0066d Pankaj Dubey 2014-09-30 91kfree(syscon); bdb0066d Pankaj Dubey 2014-09-30 92return ERR_PTR(ret); 87d68730 Dong Aisheng 2012-09-05 93 } 87d68730 Dong Aisheng 2012-09-05 94 87d68730 Dong Aisheng 2012-09-05 95 struct regmap *syscon_node_to_regmap(struct device_node *np) 87d68730 Dong Aisheng 2012-09-05 96 { bdb0066d Pankaj Dubey 2014-09-30 97struct syscon *entry, *syscon = NULL; :: The code at line 89 was first introduced by commit :: bdb0066df96e74a4002125467ebe459feff1ebef mfd: syscon: Decouple syscon interface from platform devices :: TO: Pankaj Dubey:: CC: Lee Jones --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
drivers/mfd/syscon.c:89:2: error: implicit declaration of function 'iounmap'
Hi Rob, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f7eeb8a87c033d126ff6b8c35405ba5dc4e55754 commit: 0166dc11be911213e0b1b764488c671be4c48cf3 of: make CONFIG_OF user selectable date: 10 months ago config: um-allyesconfig (attached as .config) reproduce: git checkout 0166dc11be911213e0b1b764488c671be4c48cf3 # save the attached .config to linux build tree make ARCH=um All errors (new ones prefixed by >>): drivers/mfd/syscon.c: In function 'of_syscon_register': >> drivers/mfd/syscon.c:89:2: error: implicit declaration of function 'iounmap' >> [-Werror=implicit-function-declaration] iounmap(base); ^ cc1: some warnings being treated as errors vim +/iounmap +89 drivers/mfd/syscon.c bdb0066d Pankaj Dubey 2014-09-30 73if (IS_ERR(regmap)) { bdb0066d Pankaj Dubey 2014-09-30 74pr_err("regmap init failed\n"); bdb0066d Pankaj Dubey 2014-09-30 75ret = PTR_ERR(regmap); bdb0066d Pankaj Dubey 2014-09-30 76goto err_regmap; bdb0066d Pankaj Dubey 2014-09-30 77} bdb0066d Pankaj Dubey 2014-09-30 78 bdb0066d Pankaj Dubey 2014-09-30 79syscon->regmap = regmap; bdb0066d Pankaj Dubey 2014-09-30 80syscon->np = np; bdb0066d Pankaj Dubey 2014-09-30 81 bdb0066d Pankaj Dubey 2014-09-30 82spin_lock(_list_slock); bdb0066d Pankaj Dubey 2014-09-30 83list_add_tail(>list, _list); bdb0066d Pankaj Dubey 2014-09-30 84spin_unlock(_list_slock); 87d68730 Dong Aisheng 2012-09-05 85 bdb0066d Pankaj Dubey 2014-09-30 86return syscon; bdb0066d Pankaj Dubey 2014-09-30 87 bdb0066d Pankaj Dubey 2014-09-30 88 err_regmap: bdb0066d Pankaj Dubey 2014-09-30 @89iounmap(base); bdb0066d Pankaj Dubey 2014-09-30 90 err_map: bdb0066d Pankaj Dubey 2014-09-30 91kfree(syscon); bdb0066d Pankaj Dubey 2014-09-30 92return ERR_PTR(ret); 87d68730 Dong Aisheng 2012-09-05 93 } 87d68730 Dong Aisheng 2012-09-05 94 87d68730 Dong Aisheng 2012-09-05 95 struct regmap *syscon_node_to_regmap(struct device_node *np) 87d68730 Dong Aisheng 2012-09-05 96 { bdb0066d Pankaj Dubey 2014-09-30 97struct syscon *entry, *syscon = NULL; :: The code at line 89 was first introduced by commit :: bdb0066df96e74a4002125467ebe459feff1ebef mfd: syscon: Decouple syscon interface from platform devices :: TO: Pankaj Dubey :: CC: Lee Jones --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH] ARM: dts: s3c: Fix DTC unit name warnings in S3C2416 and S3C6410
On Fri, Apr 01, 2016 at 04:22:59PM +0200, Joachim Eastwood wrote: > On 1 April 2016 at 09:11, Krzysztof Kozlowskiwrote: > > Fix following DTC warnings in S3C2416 and S3C6410 boards: > > > > Warning (unit_address_vs_reg): Node /memory has a reg or ranges property, > > but no unit name > > > > Signed-off-by: Krzysztof Kozlowski > > --- > > arch/arm/boot/dts/s3c2416-smdk2416.dts | 2 +- > > arch/arm/boot/dts/s3c6410-mini6410.dts | 2 +- > > arch/arm/boot/dts/s3c6410-smdk6410.dts | 2 +- > > 3 files changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm/boot/dts/s3c2416-smdk2416.dts > > b/arch/arm/boot/dts/s3c2416-smdk2416.dts > > index f257926c13b7..15f3d1c1bb80 100644 > > --- a/arch/arm/boot/dts/s3c2416-smdk2416.dts > > +++ b/arch/arm/boot/dts/s3c2416-smdk2416.dts > > @@ -15,7 +15,7 @@ > > model = "SMDK2416"; > > compatible = "samsung,s3c2416"; > > > > - memory { > > + memory@3000 { > > reg = <0x3000 0x400>; > > }; > > This change will cause duplicated memory node entries in the DT as > noted by Vladimir Zapolskiy [1]. Same goes for all the other patch > where you make this change. > > $ scripts/dtc/dtc -I dtb -O dts arch/arm/boot/dts/s3c2416-smdk2416.dtb > | grep -A2 memory > memory { > device_type = "memory"; > reg = <0x0 0x0>; > }; > -- > memory@3000 { > reg = <0x3000 0x400>; > }; Yeah, I also spotted this later after running scripts/dtx_diff. I will leave the memory node untouched. Thanks for feedback! Krzysztof
Re: [PATCH] ARM: dts: s3c: Fix DTC unit name warnings in S3C2416 and S3C6410
On Fri, Apr 01, 2016 at 04:22:59PM +0200, Joachim Eastwood wrote: > On 1 April 2016 at 09:11, Krzysztof Kozlowski wrote: > > Fix following DTC warnings in S3C2416 and S3C6410 boards: > > > > Warning (unit_address_vs_reg): Node /memory has a reg or ranges property, > > but no unit name > > > > Signed-off-by: Krzysztof Kozlowski > > --- > > arch/arm/boot/dts/s3c2416-smdk2416.dts | 2 +- > > arch/arm/boot/dts/s3c6410-mini6410.dts | 2 +- > > arch/arm/boot/dts/s3c6410-smdk6410.dts | 2 +- > > 3 files changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm/boot/dts/s3c2416-smdk2416.dts > > b/arch/arm/boot/dts/s3c2416-smdk2416.dts > > index f257926c13b7..15f3d1c1bb80 100644 > > --- a/arch/arm/boot/dts/s3c2416-smdk2416.dts > > +++ b/arch/arm/boot/dts/s3c2416-smdk2416.dts > > @@ -15,7 +15,7 @@ > > model = "SMDK2416"; > > compatible = "samsung,s3c2416"; > > > > - memory { > > + memory@3000 { > > reg = <0x3000 0x400>; > > }; > > This change will cause duplicated memory node entries in the DT as > noted by Vladimir Zapolskiy [1]. Same goes for all the other patch > where you make this change. > > $ scripts/dtc/dtc -I dtb -O dts arch/arm/boot/dts/s3c2416-smdk2416.dtb > | grep -A2 memory > memory { > device_type = "memory"; > reg = <0x0 0x0>; > }; > -- > memory@3000 { > reg = <0x3000 0x400>; > }; Yeah, I also spotted this later after running scripts/dtx_diff. I will leave the memory node untouched. Thanks for feedback! Krzysztof
Re: [PATCH 01/11] ARM: dts: exynos: Fix DTC unit name warnings in cros-adc-thermistors
On Fri, Apr 01, 2016 at 10:31:34AM -0500, Rob Herring wrote: > On Fri, Apr 1, 2016 at 1:57 AM, Krzysztof Kozlowski >wrote: > > Fix following DTC warnings in cros-adc-thermistors: > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@3 has a unit > > name, but no reg property > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@4 has a unit > > name, but no reg property > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@5 has a unit > > name, but no reg property > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@6 has a unit > > name, but no reg property > > > > Signed-off-by: Krzysztof Kozlowski > > --- > > arch/arm/boot/dts/cros-adc-thermistors.dtsi | 8 > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > b/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > index acd4fe1833f2..87e676917603 100644 > > --- a/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > +++ b/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > @@ -13,28 +13,28 @@ > > */ > > > > { > > - ncp15wb473@3 { > > + ncp15wb473_3 { > > Don't use underscores. The ePAPR lists underscore as a acceptable character... but if you insists then the sensible solution would be to rename all the nodes to something like: - ncp15wb473@3 { + thermistor3 { Is it okay? > > > compatible = "murata,ncp15wb473"; > > pullup-uv = <180>; > > pullup-ohm = <47000>; > > pulldown-ohm = <0>; > > io-channels = < 3>; > > I've not looked at the full binding here, but this case may warrant > adding a reg property as an ADC channel number is what i'd consider an > addressable thing. This does not look entirely as an addressable thing. Altough this particular driver (ntc_thermistor.c) uses one iio-channel... but others are often using more than one. > This is also kind of strange having a phandle to > the parent node. The Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt mentions that sensors can be added as child nodes or separately. The exynos_adc driver indeed calls of_platform_populate() but I am not sure why this was added. Best regards, Krzysztof
Re: [PATCH 01/11] ARM: dts: exynos: Fix DTC unit name warnings in cros-adc-thermistors
On Fri, Apr 01, 2016 at 10:31:34AM -0500, Rob Herring wrote: > On Fri, Apr 1, 2016 at 1:57 AM, Krzysztof Kozlowski > wrote: > > Fix following DTC warnings in cros-adc-thermistors: > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@3 has a unit > > name, but no reg property > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@4 has a unit > > name, but no reg property > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@5 has a unit > > name, but no reg property > > Warning (unit_address_vs_reg): Node /adc@12D1/ncp15wb473@6 has a unit > > name, but no reg property > > > > Signed-off-by: Krzysztof Kozlowski > > --- > > arch/arm/boot/dts/cros-adc-thermistors.dtsi | 8 > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > b/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > index acd4fe1833f2..87e676917603 100644 > > --- a/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > +++ b/arch/arm/boot/dts/cros-adc-thermistors.dtsi > > @@ -13,28 +13,28 @@ > > */ > > > > { > > - ncp15wb473@3 { > > + ncp15wb473_3 { > > Don't use underscores. The ePAPR lists underscore as a acceptable character... but if you insists then the sensible solution would be to rename all the nodes to something like: - ncp15wb473@3 { + thermistor3 { Is it okay? > > > compatible = "murata,ncp15wb473"; > > pullup-uv = <180>; > > pullup-ohm = <47000>; > > pulldown-ohm = <0>; > > io-channels = < 3>; > > I've not looked at the full binding here, but this case may warrant > adding a reg property as an ADC channel number is what i'd consider an > addressable thing. This does not look entirely as an addressable thing. Altough this particular driver (ntc_thermistor.c) uses one iio-channel... but others are often using more than one. > This is also kind of strange having a phandle to > the parent node. The Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt mentions that sensors can be added as child nodes or separately. The exynos_adc driver indeed calls of_platform_populate() but I am not sure why this was added. Best regards, Krzysztof
Re: [RT] Warning from swake_up_all_locked in rt-4.4.4-rt11
On Fri, 1 Apr 2016 12:33:18 +0200 Sebastian Andrzej Siewiorwrote: > * Thomas Gleixner | 2016-03-14 09:49:52 [+0100]: > > >On Sun, 13 Mar 2016, Clark Williams wrote: > > > >> I'm hitting the WARN_ON(wakes > 2) in $SUBJECT when resuming from suspend > >> on my laptop (quad-core i7 with HT on). Looks like the warning gets hit 36 > >> times on resume. E.g.: > >If resume is the only case, then we can filter that out and not worry about > >it > >at all :) > > This works with the "mem" and "disk" target: > > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -194,6 +194,12 @@ struct platform_freeze_ops { > void (*end)(void); > }; > > +#if defined(CONFIG_SUSPEND) || defined(CONFIG_HIBERNATION) > +extern bool pm_in_action; > +#else > +# define pm_in_action false > +#endif > + > #ifdef CONFIG_SUSPEND > /** > * suspend_set_ops - set platform dependent suspend operations > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index bfd9e0982f15..fbb23f93e8d6 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -648,6 +648,10 @@ static void power_down(void) > cpu_relax(); > } > > +#ifndef CONFIG_SUSPEND > +bool pm_in_action; > +#endif > + > /** > * hibernate - Carry out system hibernation, including saving the image. > */ > @@ -660,6 +664,8 @@ int hibernate(void) > return -EPERM; > } > > + pm_in_action = true; > + > lock_system_sleep(); > /* The snapshot device should not be opened while we're running */ > if (!atomic_add_unless(_device_available, -1, 0)) { > @@ -725,6 +731,7 @@ int hibernate(void) > atomic_inc(_device_available); > Unlock: > unlock_system_sleep(); > + pm_in_action = false; > return error; > } > > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > index 80ebc0726290..393bc342c586 100644 > --- a/kernel/power/suspend.c > +++ b/kernel/power/suspend.c > @@ -522,6 +522,8 @@ static int enter_state(suspend_state_t state) > return error; > } > > +bool pm_in_action; > + > /** > * pm_suspend - Externally visible function for suspending the system. > * @state: System sleep state to enter. > @@ -536,6 +538,8 @@ int pm_suspend(suspend_state_t state) > if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) > return -EINVAL; > > + pm_in_action = true; > + > error = enter_state(state); > if (error) { > suspend_stats.fail++; > @@ -543,6 +547,7 @@ int pm_suspend(suspend_state_t state) > } else { > suspend_stats.success++; > } > + pm_in_action = false; > return error; > } > EXPORT_SYMBOL(pm_suspend); > diff --git a/kernel/sched/swait.c b/kernel/sched/swait.c > index 8459561f0379..205fe36868f9 100644 > --- a/kernel/sched/swait.c > +++ b/kernel/sched/swait.c > @@ -1,5 +1,6 @@ > #include > #include > +#include > > void __init_swait_queue_head(struct swait_queue_head *q, const char *name, >struct lock_class_key *key) > @@ -42,7 +43,9 @@ void swake_up_all_locked(struct swait_queue_head *q) > list_del_init(>task_list); > wakes++; > } > - WARN_ON(wakes > 2); > + if (pm_in_action) > + return; > + WARN(wakes > 2, "complate_all() with %d waiters\n", wakes); > } > EXPORT_SYMBOL(swake_up_all_locked); > > Sebastian Applied to 4.4.6-rt12, suspended/resumed multiple times with no warnings from swake_up_all_locked(). Tested-by: Clark Williams pgpC3rI49SWCG.pgp Description: OpenPGP digital signature
Re: [RT] Warning from swake_up_all_locked in rt-4.4.4-rt11
On Fri, 1 Apr 2016 12:33:18 +0200 Sebastian Andrzej Siewior wrote: > * Thomas Gleixner | 2016-03-14 09:49:52 [+0100]: > > >On Sun, 13 Mar 2016, Clark Williams wrote: > > > >> I'm hitting the WARN_ON(wakes > 2) in $SUBJECT when resuming from suspend > >> on my laptop (quad-core i7 with HT on). Looks like the warning gets hit 36 > >> times on resume. E.g.: > >If resume is the only case, then we can filter that out and not worry about > >it > >at all :) > > This works with the "mem" and "disk" target: > > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -194,6 +194,12 @@ struct platform_freeze_ops { > void (*end)(void); > }; > > +#if defined(CONFIG_SUSPEND) || defined(CONFIG_HIBERNATION) > +extern bool pm_in_action; > +#else > +# define pm_in_action false > +#endif > + > #ifdef CONFIG_SUSPEND > /** > * suspend_set_ops - set platform dependent suspend operations > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index bfd9e0982f15..fbb23f93e8d6 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -648,6 +648,10 @@ static void power_down(void) > cpu_relax(); > } > > +#ifndef CONFIG_SUSPEND > +bool pm_in_action; > +#endif > + > /** > * hibernate - Carry out system hibernation, including saving the image. > */ > @@ -660,6 +664,8 @@ int hibernate(void) > return -EPERM; > } > > + pm_in_action = true; > + > lock_system_sleep(); > /* The snapshot device should not be opened while we're running */ > if (!atomic_add_unless(_device_available, -1, 0)) { > @@ -725,6 +731,7 @@ int hibernate(void) > atomic_inc(_device_available); > Unlock: > unlock_system_sleep(); > + pm_in_action = false; > return error; > } > > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > index 80ebc0726290..393bc342c586 100644 > --- a/kernel/power/suspend.c > +++ b/kernel/power/suspend.c > @@ -522,6 +522,8 @@ static int enter_state(suspend_state_t state) > return error; > } > > +bool pm_in_action; > + > /** > * pm_suspend - Externally visible function for suspending the system. > * @state: System sleep state to enter. > @@ -536,6 +538,8 @@ int pm_suspend(suspend_state_t state) > if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) > return -EINVAL; > > + pm_in_action = true; > + > error = enter_state(state); > if (error) { > suspend_stats.fail++; > @@ -543,6 +547,7 @@ int pm_suspend(suspend_state_t state) > } else { > suspend_stats.success++; > } > + pm_in_action = false; > return error; > } > EXPORT_SYMBOL(pm_suspend); > diff --git a/kernel/sched/swait.c b/kernel/sched/swait.c > index 8459561f0379..205fe36868f9 100644 > --- a/kernel/sched/swait.c > +++ b/kernel/sched/swait.c > @@ -1,5 +1,6 @@ > #include > #include > +#include > > void __init_swait_queue_head(struct swait_queue_head *q, const char *name, >struct lock_class_key *key) > @@ -42,7 +43,9 @@ void swake_up_all_locked(struct swait_queue_head *q) > list_del_init(>task_list); > wakes++; > } > - WARN_ON(wakes > 2); > + if (pm_in_action) > + return; > + WARN(wakes > 2, "complate_all() with %d waiters\n", wakes); > } > EXPORT_SYMBOL(swake_up_all_locked); > > Sebastian Applied to 4.4.6-rt12, suspended/resumed multiple times with no warnings from swake_up_all_locked(). Tested-by: Clark Williams pgpC3rI49SWCG.pgp Description: OpenPGP digital signature
[PATCH v2] PM / runtime: Document steps for device removal
Put a reminder that during device removal drivers should revert all PM runtime changes from the probe. Signed-off-by: Krzysztof Kozlowski--- Changes since v1: 1. Address Alan's comments. --- Documentation/power/runtime_pm.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt index 7328cf85236c..1fd1fbe9ce95 100644 --- a/Documentation/power/runtime_pm.txt +++ b/Documentation/power/runtime_pm.txt @@ -586,6 +586,10 @@ drivers to make their ->remove() callbacks avoid races with runtime PM directly, but also it allows of more flexibility in the handling of devices during the removal of their drivers. +Drivers in ->remove() callback should undo the runtime PM changes done +in ->probe(). Usually this means calling pm_runtime_disable(), +pm_runtime_dont_use_autosuspend() etc. + The user space can effectively disallow the driver of the device to power manage it at run time by changing the value of its /sys/devices/.../power/control attribute to "on", which causes pm_runtime_forbid() to be called. In principle, -- 2.1.4
[PATCH v2] PM / runtime: Document steps for device removal
Put a reminder that during device removal drivers should revert all PM runtime changes from the probe. Signed-off-by: Krzysztof Kozlowski --- Changes since v1: 1. Address Alan's comments. --- Documentation/power/runtime_pm.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt index 7328cf85236c..1fd1fbe9ce95 100644 --- a/Documentation/power/runtime_pm.txt +++ b/Documentation/power/runtime_pm.txt @@ -586,6 +586,10 @@ drivers to make their ->remove() callbacks avoid races with runtime PM directly, but also it allows of more flexibility in the handling of devices during the removal of their drivers. +Drivers in ->remove() callback should undo the runtime PM changes done +in ->probe(). Usually this means calling pm_runtime_disable(), +pm_runtime_dont_use_autosuspend() etc. + The user space can effectively disallow the driver of the device to power manage it at run time by changing the value of its /sys/devices/.../power/control attribute to "on", which causes pm_runtime_forbid() to be called. In principle, -- 2.1.4
Re: [PATCH 06/11] ARM: dts: exynos: Fix DTC unit name warnings in Exynos5250
On Fri, Apr 01, 2016 at 01:21:45PM -0400, Javier Martinez Canillas wrote: > > > > - usb@1200 { > > + usb_dwc3 { > > compatible = "samsung,exynos5250-dwusb3"; > > clocks = < CLK_USB3>; > > clock-names = "usbdrd30"; > > The ePAPR document says that "The name of a node should be somewhat generic, > reflecting the function of the device and not its precise programming model" > > So I wonder if this shouldn't be instead: > > usb_dwc3: usb { There are already nodes with 'usb' name: ehci: usb@1211 { compatible = "samsung,exynos4210-ehci"; ... } ohci: usb@1212 { compatible = "samsung,exynos4210-ohci"; } Having nodes with the same name but some with address some not, should work (none should be overridden)... but looks a little bit weird. Anyway I am fine with both. > Although it seems that not all DT bindings follow this convention so probably > the name in your patch is correct. > > Reviewed-by: Javier Martinez CanillasThanks for review and comments. I already spotted the 'memory' node issue so I won't be replying to you with acknowledging comments. :) BR, Krzysztof
Re: [PATCH 06/11] ARM: dts: exynos: Fix DTC unit name warnings in Exynos5250
On Fri, Apr 01, 2016 at 01:21:45PM -0400, Javier Martinez Canillas wrote: > > > > - usb@1200 { > > + usb_dwc3 { > > compatible = "samsung,exynos5250-dwusb3"; > > clocks = < CLK_USB3>; > > clock-names = "usbdrd30"; > > The ePAPR document says that "The name of a node should be somewhat generic, > reflecting the function of the device and not its precise programming model" > > So I wonder if this shouldn't be instead: > > usb_dwc3: usb { There are already nodes with 'usb' name: ehci: usb@1211 { compatible = "samsung,exynos4210-ehci"; ... } ohci: usb@1212 { compatible = "samsung,exynos4210-ohci"; } Having nodes with the same name but some with address some not, should work (none should be overridden)... but looks a little bit weird. Anyway I am fine with both. > Although it seems that not all DT bindings follow this convention so probably > the name in your patch is correct. > > Reviewed-by: Javier Martinez Canillas Thanks for review and comments. I already spotted the 'memory' node issue so I won't be replying to you with acknowledging comments. :) BR, Krzysztof
[bisect] Merge tag 'mmc-v4.6' of git://git.linaro.org/people/ulf.hansson/mmc (was [GIT PULL] MMC for v.4.6)
On 03/21/2016 05:59 AM, Ulf Hansson wrote: > Hi Linus, > > Here's the PR for MMC v4.6. > > Details about the highlights are as usual found in the signed tag. > > Please pull this in! > > Kind regards > Ulf Hansson > > > The following changes since commit fc77dbd34c5c99bce46d40a2491937c3bcbd10af: > > Linux 4.5-rc6 (2016-02-28 08:41:20 -0800) > > are available in the git repository at: > > git://git.linaro.org/people/ulf.hansson/mmc.git tags/mmc-v4.6 > > for you to fetch changes up to 64e5cd723120643a4c8bef0880a03a60161d3ccb: > > mmc: sdhci-of-at91: fix wake-up issue when using runtime pm > (2016-03-18 09:12:32 +0100) This merge commit e531cdf50a8a0fb7a4d51c06e52097bd01e9bf7c Merge: 4526b71 64e5cd7 Author: Linus TorvaldsDate: Mon Mar 21 14:35:52 2016 -0700 Merge tag 'mmc-v4.6' of git://git.linaro.org/people/ulf.hansson/mmc Pull MMC updates from Ulf Hansson: ... is fingered by git bisect as the cause for a mashup of mmc block devices on a Beaglebone Black: [2.916209] mmc1: new high speed MMC card at address 0001 [2.923755] mmcblk0: mmc1:0001 MMC04G 3.60 GiB [2.929479] mmcblk0boot0: mmc1:0001 MMC04G partition 1 2.00 MiB [2.936821] tps65217 0-0024: TPS65217 ID 0xe version 1.2 [2.942270] mmcblk0boot1: mmc1:0001 MMC04G partition 2 2.00 MiB [2.949388] mmcblk0: p1 p2 [2.950031] mmc0: new high speed SDHC card at address e624 [2.961118] mmcblk1: mmc0:e624 SU08G 7.40 GiB [2.967047] at24 0-0050: 32768 byte 24c256 EEPROM, writable, 1 bytes/write [2.974190] mmcblk1: p1 p2 Note how mmc1 => mmcblk0 and mmc0 => mmcblk1. This produces a failure to boot as the wrong partition is mounted as root (/dev/mmcblk0p2 is now on the wrong mmc). The bisect tried all the mmc tree patches which were all good. I double-checked by cloning the mmc tree and building both mmc-v4.6 and v4.5-rc6, and both tested good. I interpret that to mean some change in mmc + some new behavior elsewhere for v4.6 is causing this. Any ideas? Regards, Peter Hurley
[bisect] Merge tag 'mmc-v4.6' of git://git.linaro.org/people/ulf.hansson/mmc (was [GIT PULL] MMC for v.4.6)
On 03/21/2016 05:59 AM, Ulf Hansson wrote: > Hi Linus, > > Here's the PR for MMC v4.6. > > Details about the highlights are as usual found in the signed tag. > > Please pull this in! > > Kind regards > Ulf Hansson > > > The following changes since commit fc77dbd34c5c99bce46d40a2491937c3bcbd10af: > > Linux 4.5-rc6 (2016-02-28 08:41:20 -0800) > > are available in the git repository at: > > git://git.linaro.org/people/ulf.hansson/mmc.git tags/mmc-v4.6 > > for you to fetch changes up to 64e5cd723120643a4c8bef0880a03a60161d3ccb: > > mmc: sdhci-of-at91: fix wake-up issue when using runtime pm > (2016-03-18 09:12:32 +0100) This merge commit e531cdf50a8a0fb7a4d51c06e52097bd01e9bf7c Merge: 4526b71 64e5cd7 Author: Linus Torvalds Date: Mon Mar 21 14:35:52 2016 -0700 Merge tag 'mmc-v4.6' of git://git.linaro.org/people/ulf.hansson/mmc Pull MMC updates from Ulf Hansson: ... is fingered by git bisect as the cause for a mashup of mmc block devices on a Beaglebone Black: [2.916209] mmc1: new high speed MMC card at address 0001 [2.923755] mmcblk0: mmc1:0001 MMC04G 3.60 GiB [2.929479] mmcblk0boot0: mmc1:0001 MMC04G partition 1 2.00 MiB [2.936821] tps65217 0-0024: TPS65217 ID 0xe version 1.2 [2.942270] mmcblk0boot1: mmc1:0001 MMC04G partition 2 2.00 MiB [2.949388] mmcblk0: p1 p2 [2.950031] mmc0: new high speed SDHC card at address e624 [2.961118] mmcblk1: mmc0:e624 SU08G 7.40 GiB [2.967047] at24 0-0050: 32768 byte 24c256 EEPROM, writable, 1 bytes/write [2.974190] mmcblk1: p1 p2 Note how mmc1 => mmcblk0 and mmc0 => mmcblk1. This produces a failure to boot as the wrong partition is mounted as root (/dev/mmcblk0p2 is now on the wrong mmc). The bisect tried all the mmc tree patches which were all good. I double-checked by cloning the mmc tree and building both mmc-v4.6 and v4.5-rc6, and both tested good. I interpret that to mean some change in mmc + some new behavior elsewhere for v4.6 is causing this. Any ideas? Regards, Peter Hurley
Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.
On Sat, Apr 02, 2016 at 11:46:21PM +, KY Srinivasan wrote: > > > > -Original Message- > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > Sent: Saturday, April 2, 2016 3:23 PM > > To: KY Srinivasan> > Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; > > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com; > > jasow...@redhat.com > > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > > management. > > > > On Sat, Apr 02, 2016 at 11:10:38AM -0700, K. Y. Srinivasan wrote: > > > Cleanup and mmio management. Also included is a patch > > > to fix an issue in KVP. > > > > So these all are for 4.7-rc1? > > Jake's PCI driver made it into 4.6 and some of the patches in this series fix > issues in the Hyper-V > PCI pass-through driver. Is it possible for this series to go into 4.6. If > not, 4.7-rc1 is fine. Even patch 1? Please be specific where you want patches to be merged to. greg k-h
Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.
On Sat, Apr 02, 2016 at 11:46:21PM +, KY Srinivasan wrote: > > > > -Original Message- > > From: Greg KH [mailto:gre...@linuxfoundation.org] > > Sent: Saturday, April 2, 2016 3:23 PM > > To: KY Srinivasan > > Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; > > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com; > > jasow...@redhat.com > > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > > management. > > > > On Sat, Apr 02, 2016 at 11:10:38AM -0700, K. Y. Srinivasan wrote: > > > Cleanup and mmio management. Also included is a patch > > > to fix an issue in KVP. > > > > So these all are for 4.7-rc1? > > Jake's PCI driver made it into 4.6 and some of the patches in this series fix > issues in the Hyper-V > PCI pass-through driver. Is it possible for this series to go into 4.6. If > not, 4.7-rc1 is fine. Even patch 1? Please be specific where you want patches to be merged to. greg k-h
Re: [GIT PULL] Thermal SoC management updates for v4.6-rc2
On Sat, Apr 02, 2016 at 08:09:08PM -0500, Linus Torvalds wrote: > On Sat, Apr 2, 2016 at 8:04 PM, Eduardo Valentinwrote: > > > > Please pull from > > > > git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal > > fixes > > > > to receive Thermal-SoC Management updates for v4.6-rc2 with top-most > > This is not a "fixes" pull. > > This is a merge window pull, long after the merge window has closed. > > Not pulled. OK. Redirecting this material to 4.7-rc1 then. Thanks, Eduardo Valentin > > Linus
Re: [GIT PULL] Thermal SoC management updates for v4.6-rc2
On Sat, Apr 02, 2016 at 08:09:08PM -0500, Linus Torvalds wrote: > On Sat, Apr 2, 2016 at 8:04 PM, Eduardo Valentin wrote: > > > > Please pull from > > > > git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal > > fixes > > > > to receive Thermal-SoC Management updates for v4.6-rc2 with top-most > > This is not a "fixes" pull. > > This is a merge window pull, long after the merge window has closed. > > Not pulled. OK. Redirecting this material to 4.7-rc1 then. Thanks, Eduardo Valentin > > Linus
Hilsener.
God dag, Jeg trenger en utenlandsk partner for en gjensidig virksomhet forslag, som er relatert til overføring av en stor sum penger til en utenlandsk konto, som mottaker av midlene. Alt om denne transaksjonen vil bli gjort lovlig uten bro av økonomisk autoritet både i mitt land og yours.I wil hengi deg til å observere ytterste skjønn i alle saker knyttet til dette problemet. Hvis du er interessert, kan du svare tilbake via min private e-postadresse er skrevet under, vil jeg gi deg mer informasjon om meg selv med finans institusjonen jeg representerte og faktiske beløpene innebærer om prosjektet så snart jeg får positiv respons. Privat e-post:zhongju...@yahoo.com.hk Vennlig hilsen, Daglig leder.
Hilsener.
God dag, Jeg trenger en utenlandsk partner for en gjensidig virksomhet forslag, som er relatert til overføring av en stor sum penger til en utenlandsk konto, som mottaker av midlene. Alt om denne transaksjonen vil bli gjort lovlig uten bro av økonomisk autoritet både i mitt land og yours.I wil hengi deg til å observere ytterste skjønn i alle saker knyttet til dette problemet. Hvis du er interessert, kan du svare tilbake via min private e-postadresse er skrevet under, vil jeg gi deg mer informasjon om meg selv med finans institusjonen jeg representerte og faktiske beløpene innebærer om prosjektet så snart jeg får positiv respons. Privat e-post:zhongju...@yahoo.com.hk Vennlig hilsen, Daglig leder.
Re: [GIT PULL] Thermal SoC management updates for v4.6-rc2
On Sat, Apr 2, 2016 at 8:04 PM, Eduardo Valentinwrote: > > Please pull from > > git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal > fixes > > to receive Thermal-SoC Management updates for v4.6-rc2 with top-most This is not a "fixes" pull. This is a merge window pull, long after the merge window has closed. Not pulled. Linus
Re: [GIT PULL] Thermal SoC management updates for v4.6-rc2
On Sat, Apr 2, 2016 at 8:04 PM, Eduardo Valentin wrote: > > Please pull from > > git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal > fixes > > to receive Thermal-SoC Management updates for v4.6-rc2 with top-most This is not a "fixes" pull. This is a merge window pull, long after the merge window has closed. Not pulled. Linus
[GIT PULL] Thermal SoC management updates for v4.6-rc2
Hello Linus, Please pull from git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal fixes to receive Thermal-SoC Management updates for v4.6-rc2 with top-most c960fe12d00275c52dffc0013d64c5a50538a74c: thermal: hisilicon: fix IRQ imbalance enabling (2016-03-29 08:43:02 -0700) on top of commit f55532a0c0b8bb6148f4e07853b876ef73bc69ca: Linux 4.6-rc1 (2016-03-26 16:03:24 -0700) Specifics in this pull request: - Fixes in thermal sysfs API documentation - Rework of OF thermal users to migrate to devm_ helper - Adding Keerthy as maintainer of TI thermal SoC - Minor fixes on Hisilicon, RCAR, and OF thermal. - Code refactoring and reorganization on tegra thermal driver. - These change have been CI tested using KernelCI bot [1,2]. \o/ [1] - https://kernelci.org/boot/all/job/evalenti/kernel/v4.6-rc1-30-gc960fe12d002/ [2] - https://kernelci.org/build/evalenti/kernel/v4.6-rc1-30-gc960fe12d002/ BR, Eduardo Valentin Andy Champ (1): thermal: Syntactic and factual errors in the API document Eduardo Valentin (12): hwmon: convert lm75 to use devm_thermal_zone_of_sensor_register hwmon: convert ntc_thermistor to use devm_thermal_zone_of_sensor_register hwmon: convert tmp102 to use devm_thermal_zone_of_sensor_register hwmon: convert scpi-hwmon to use devm_thermal_zone_of_sensor_register input: convert sun4i-ts to use devm_thermal_zone_of_sensor_register thermal: convert hisi_thermal to use devm_thermal_zone_of_sensor_register thermal: convert mtk_thermal to use devm_thermal_zone_of_sensor_register thermal: convert qcom-spmi to use devm_thermal_zone_of_sensor_register thermal: convert rcar_thermal to use devm_thermal_zone_of_sensor_register thermal: convert rockchip_thermal to use devm_thermal_zone_of_sensor_register thermal: convert tegra_thermal to use devm_thermal_zone_of_sensor_register thermal: convert ti-thermal to use devm_thermal_zone_of_sensor_register Keerthy (1): MAINTAINERS: ti-soc-thermal: add a co-maintainer and update the entry Leo Yan (2): thermal: hisilicon: support to use any sensor thermal: hisilicon: fix IRQ imbalance enabling Simon Horman (1): thermal: rcar: Remove binding docs for r8a7794 Ulises Brindis (1): thermal: of: fix cleanup when building a thermal zone Wei Ni (12): thermal: tegra: move tegra thermal files into tegra directory thermal: tegra: combine sensor group-related data thermal: tegra: get rid of PDIV/HOTSPOT hack thermal: tegra: split tegra_soctherm driver thermal: tegra: add Tegra210 specific SOC_THERM driver thermal: tegra: add a debugfs to show registers thermal: of-thermal: allow setting trip_temp on hardware of: add notes of critical trips for soctherm thermal: tegra: add thermtrip function thermal: tegra: handle clocks in one function thermal: tegra: handle HW initialization in one funcotion thermal: tegra: add PM support .../devicetree/bindings/thermal/rcar-thermal.txt | 1 - .../devicetree/bindings/thermal/tegra-soctherm.txt | 12 + Documentation/thermal/sysfs-api.txt| 44 +- MAINTAINERS| 1 + drivers/hwmon/lm75.c | 10 +- drivers/hwmon/ntc_thermistor.c | 12 +- drivers/hwmon/scpi-hwmon.c | 48 +- drivers/hwmon/tmp102.c | 8 +- drivers/input/touchscreen/sun4i-ts.c | 9 +- drivers/thermal/Kconfig| 12 +- drivers/thermal/Makefile | 2 +- drivers/thermal/hisi_thermal.c | 45 +- drivers/thermal/mtk_thermal.c | 12 +- drivers/thermal/of-thermal.c | 10 +- drivers/thermal/qcom-spmi-temp-alarm.c | 3 +- drivers/thermal/rcar_thermal.c | 2 +- drivers/thermal/rockchip_thermal.c | 17 +- drivers/thermal/tegra/Kconfig | 13 + drivers/thermal/tegra/Makefile | 5 + drivers/thermal/tegra/soctherm-fuse.c | 169 + drivers/thermal/tegra/soctherm.c | 682 + drivers/thermal/tegra/soctherm.h | 123 drivers/thermal/tegra/tegra124-soctherm.c | 196 ++ drivers/thermal/tegra/tegra210-soctherm.c | 197 ++ drivers/thermal/tegra_soctherm.c | 476 -- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 5 +- include/dt-bindings/thermal/tegra124-soctherm.h| 1 + include/linux/thermal.h| 1 + 28 files changed, 1488 insertions(+), 628 deletions(-) create mode 100644 drivers/thermal/tegra/Kconfig create mode 100644 drivers/thermal/tegra/Makefile create mode
[GIT PULL] Thermal SoC management updates for v4.6-rc2
Hello Linus, Please pull from git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal fixes to receive Thermal-SoC Management updates for v4.6-rc2 with top-most c960fe12d00275c52dffc0013d64c5a50538a74c: thermal: hisilicon: fix IRQ imbalance enabling (2016-03-29 08:43:02 -0700) on top of commit f55532a0c0b8bb6148f4e07853b876ef73bc69ca: Linux 4.6-rc1 (2016-03-26 16:03:24 -0700) Specifics in this pull request: - Fixes in thermal sysfs API documentation - Rework of OF thermal users to migrate to devm_ helper - Adding Keerthy as maintainer of TI thermal SoC - Minor fixes on Hisilicon, RCAR, and OF thermal. - Code refactoring and reorganization on tegra thermal driver. - These change have been CI tested using KernelCI bot [1,2]. \o/ [1] - https://kernelci.org/boot/all/job/evalenti/kernel/v4.6-rc1-30-gc960fe12d002/ [2] - https://kernelci.org/build/evalenti/kernel/v4.6-rc1-30-gc960fe12d002/ BR, Eduardo Valentin Andy Champ (1): thermal: Syntactic and factual errors in the API document Eduardo Valentin (12): hwmon: convert lm75 to use devm_thermal_zone_of_sensor_register hwmon: convert ntc_thermistor to use devm_thermal_zone_of_sensor_register hwmon: convert tmp102 to use devm_thermal_zone_of_sensor_register hwmon: convert scpi-hwmon to use devm_thermal_zone_of_sensor_register input: convert sun4i-ts to use devm_thermal_zone_of_sensor_register thermal: convert hisi_thermal to use devm_thermal_zone_of_sensor_register thermal: convert mtk_thermal to use devm_thermal_zone_of_sensor_register thermal: convert qcom-spmi to use devm_thermal_zone_of_sensor_register thermal: convert rcar_thermal to use devm_thermal_zone_of_sensor_register thermal: convert rockchip_thermal to use devm_thermal_zone_of_sensor_register thermal: convert tegra_thermal to use devm_thermal_zone_of_sensor_register thermal: convert ti-thermal to use devm_thermal_zone_of_sensor_register Keerthy (1): MAINTAINERS: ti-soc-thermal: add a co-maintainer and update the entry Leo Yan (2): thermal: hisilicon: support to use any sensor thermal: hisilicon: fix IRQ imbalance enabling Simon Horman (1): thermal: rcar: Remove binding docs for r8a7794 Ulises Brindis (1): thermal: of: fix cleanup when building a thermal zone Wei Ni (12): thermal: tegra: move tegra thermal files into tegra directory thermal: tegra: combine sensor group-related data thermal: tegra: get rid of PDIV/HOTSPOT hack thermal: tegra: split tegra_soctherm driver thermal: tegra: add Tegra210 specific SOC_THERM driver thermal: tegra: add a debugfs to show registers thermal: of-thermal: allow setting trip_temp on hardware of: add notes of critical trips for soctherm thermal: tegra: add thermtrip function thermal: tegra: handle clocks in one function thermal: tegra: handle HW initialization in one funcotion thermal: tegra: add PM support .../devicetree/bindings/thermal/rcar-thermal.txt | 1 - .../devicetree/bindings/thermal/tegra-soctherm.txt | 12 + Documentation/thermal/sysfs-api.txt| 44 +- MAINTAINERS| 1 + drivers/hwmon/lm75.c | 10 +- drivers/hwmon/ntc_thermistor.c | 12 +- drivers/hwmon/scpi-hwmon.c | 48 +- drivers/hwmon/tmp102.c | 8 +- drivers/input/touchscreen/sun4i-ts.c | 9 +- drivers/thermal/Kconfig| 12 +- drivers/thermal/Makefile | 2 +- drivers/thermal/hisi_thermal.c | 45 +- drivers/thermal/mtk_thermal.c | 12 +- drivers/thermal/of-thermal.c | 10 +- drivers/thermal/qcom-spmi-temp-alarm.c | 3 +- drivers/thermal/rcar_thermal.c | 2 +- drivers/thermal/rockchip_thermal.c | 17 +- drivers/thermal/tegra/Kconfig | 13 + drivers/thermal/tegra/Makefile | 5 + drivers/thermal/tegra/soctherm-fuse.c | 169 + drivers/thermal/tegra/soctherm.c | 682 + drivers/thermal/tegra/soctherm.h | 123 drivers/thermal/tegra/tegra124-soctherm.c | 196 ++ drivers/thermal/tegra/tegra210-soctherm.c | 197 ++ drivers/thermal/tegra_soctherm.c | 476 -- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 5 +- include/dt-bindings/thermal/tegra124-soctherm.h| 1 + include/linux/thermal.h| 1 + 28 files changed, 1488 insertions(+), 628 deletions(-) create mode 100644 drivers/thermal/tegra/Kconfig create mode 100644 drivers/thermal/tegra/Makefile create mode
collect2: error: ld returned 1 exit status
Hi Anton, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: d6c24df08255e24dbd19b52dd322f61fbc30b11d commit: 238abecde8ad43f914e095fcf23e0bd35dc7a7f2 powerpc: Don't use gcc specific options on clang date: 10 months ago config: powerpc-defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 238abecde8ad43f914e095fcf23e0bd35dc7a7f2 # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/sigtramp.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/sigtramp.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/gettimeofday.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/gettimeofday.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/datapage.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/datapage.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/cacheflush.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/cacheflush.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/note.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/note.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/getcpu.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/getcpu.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[0] FDE at 04c4 overlaps table[1] FDE at 0c30. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[1] FDE at 0c30 overlaps table[2] FDE at 0c88. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[2] FDE at 0c88 overlaps table[3] FDE at 0ca0. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[3] FDE at 0ca0 overlaps table[4] FDE at 0cb8. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[4] FDE at 0cb8 overlaps table[5] FDE at 0cd0. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[5] FDE at 0cd0 overlaps table[6] FDE at 0864. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[7] FDE at 0c48 overlaps table[8] FDE at 0c5c. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[8] FDE at 0c5c overlaps table[9] FDE at 0c18. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[9] FDE at 0c18 overlaps table[10] FDE at 0c74. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[10] FDE at 0c74 overlaps table[11] FDE at 0ce8. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[11] FDE at 0ce8 overlaps table[12] FDE at 0cfc. >> collect2: error: ld returned 1 exit status --
collect2: error: ld returned 1 exit status
Hi Anton, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: d6c24df08255e24dbd19b52dd322f61fbc30b11d commit: 238abecde8ad43f914e095fcf23e0bd35dc7a7f2 powerpc: Don't use gcc specific options on clang date: 10 months ago config: powerpc-defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 238abecde8ad43f914e095fcf23e0bd35dc7a7f2 # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/sigtramp.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/sigtramp.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/gettimeofday.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/gettimeofday.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/datapage.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/datapage.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/cacheflush.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/cacheflush.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/note.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/note.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: arch/powerpc/kernel/vdso32/getcpu.o: compiled for a little endian system and target is big endian /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: failed to merge target specific data of file arch/powerpc/kernel/vdso32/getcpu.o /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[0] FDE at 04c4 overlaps table[1] FDE at 0c30. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[1] FDE at 0c30 overlaps table[2] FDE at 0c88. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[2] FDE at 0c88 overlaps table[3] FDE at 0ca0. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[3] FDE at 0ca0 overlaps table[4] FDE at 0cb8. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[4] FDE at 0cb8 overlaps table[5] FDE at 0cd0. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[5] FDE at 0cd0 overlaps table[6] FDE at 0864. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[7] FDE at 0c48 overlaps table[8] FDE at 0c5c. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[8] FDE at 0c5c overlaps table[9] FDE at 0c18. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[9] FDE at 0c18 overlaps table[10] FDE at 0c74. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[10] FDE at 0c74 overlaps table[11] FDE at 0ce8. /usr/lib/gcc-cross/powerpc64le-linux-gnu/5/../../../../powerpc64le-linux-gnu/bin/ld: .eh_frame_hdr table[11] FDE at 0ce8 overlaps table[12] FDE at 0cfc. >> collect2: error: ld returned 1 exit status --
arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (240) for 'rur240'
Hi Piet, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: d6c24df08255e24dbd19b52dd322f61fbc30b11d commit: 2c684d892bb2ee31cc48f4a8b91e86a0f15e82f9 xtensa: add Three Core HiFi-2 MX Variant. date: 2 weeks ago config: xtensa-smp_lx200_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 2c684d892bb2ee31cc48f4a8b91e86a0f15e82f9 # save the attached .config to linux build tree make.cross ARCH=xtensa All errors (new ones prefixed by >>): arch/xtensa/kernel/coprocessor.S: Assembler messages: >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (240) >> for 'rur240' >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (241) >> for 'rur241' >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (242) >> for 'rur242' >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (243) >> for 'rur243' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (240) >> for 'wur240' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (241) >> for 'wur241' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (242) >> for 'wur242' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (243) >> for 'wur243' -- arch/xtensa/include/asm/processor.h: Assembler messages: >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' -- arch/xtensa/kernel/head.S: Assembler messages: >> arch/xtensa/kernel/head.S:187: Error: unknown opcode or format name 'wer' arch/xtensa/kernel/head.S:317: Error: unknown opcode or format name 'wer' -- arch/xtensa/include/asm/processor.h: Assembler messages: >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' vim +/rur240 +93 arch/xtensa/kernel/coprocessor.S c658eac6 Chris Zankel 2008-02-12 87 .else; \ c658eac6 Chris Zankel 2008-02-12 88 .long 0; \ c658eac6 Chris Zankel 2008-02-12 89 .endif; \ c658eac6 Chris Zankel 2008-02-12 90 .long THREAD_XTREGS_CP##x 5a0015d6 Chris Zankel 2005-06-23 91 c658eac6 Chris Zankel 2008-02-12 92 SAVE_CP_REGS(0) c658eac6 Chris Zankel 2008-02-12 @93 SAVE_CP_REGS(1) c658eac6 Chris Zankel 2008-02-12 94 SAVE_CP_REGS(2) c658eac6 Chris Zankel 2008-02-12 95 SAVE_CP_REGS(3) c658eac6 Chris Zankel
arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (240) for 'rur240'
Hi Piet, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: d6c24df08255e24dbd19b52dd322f61fbc30b11d commit: 2c684d892bb2ee31cc48f4a8b91e86a0f15e82f9 xtensa: add Three Core HiFi-2 MX Variant. date: 2 weeks ago config: xtensa-smp_lx200_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 2c684d892bb2ee31cc48f4a8b91e86a0f15e82f9 # save the attached .config to linux build tree make.cross ARCH=xtensa All errors (new ones prefixed by >>): arch/xtensa/kernel/coprocessor.S: Assembler messages: >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (240) >> for 'rur240' >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (241) >> for 'rur241' >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (242) >> for 'rur242' >> arch/xtensa/kernel/coprocessor.S:93: Error: invalid register number (243) >> for 'rur243' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sp24x2s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_sq56s.i' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (240) >> for 'wur240' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (241) >> for 'wur241' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (242) >> for 'wur242' >> arch/xtensa/kernel/coprocessor.S:102: Error: invalid register number (243) >> for 'wur243' -- arch/xtensa/include/asm/processor.h: Assembler messages: >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' >> arch/xtensa/include/asm/processor.h:233: Error: unknown opcode or format >> name 'rer' -- arch/xtensa/kernel/head.S: Assembler messages: >> arch/xtensa/kernel/head.S:187: Error: unknown opcode or format name 'wer' arch/xtensa/kernel/head.S:317: Error: unknown opcode or format name 'wer' -- arch/xtensa/include/asm/processor.h: Assembler messages: >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' >> arch/xtensa/include/asm/processor.h:227: Error: unknown opcode or format >> name 'wer' vim +/rur240 +93 arch/xtensa/kernel/coprocessor.S c658eac6 Chris Zankel 2008-02-12 87 .else; \ c658eac6 Chris Zankel 2008-02-12 88 .long 0; \ c658eac6 Chris Zankel 2008-02-12 89 .endif; \ c658eac6 Chris Zankel 2008-02-12 90 .long THREAD_XTREGS_CP##x 5a0015d6 Chris Zankel 2005-06-23 91 c658eac6 Chris Zankel 2008-02-12 92 SAVE_CP_REGS(0) c658eac6 Chris Zankel 2008-02-12 @93 SAVE_CP_REGS(1) c658eac6 Chris Zankel 2008-02-12 94 SAVE_CP_REGS(2) c658eac6 Chris Zankel 2008-02-12 95 SAVE_CP_REGS(3) c658eac6 Chris Zankel
Re: [PATCH v2 net-next] net: hns: add support of pause frame ctrl for HNS V2
From: Yisen ZhuangDate: Thu, 31 Mar 2016 21:00:09 +0800 > From: Lisheng > > The patch adds support of pause ctrl for HNS V2, and this feature is lost > by HNS V1: >1) service ports can disable rx pause frame, >2) debug ports can open tx/rx pause frame. > > And this patch updates the REGs about the pause ctrl when updated > status function called by upper layer routine. > > Signed-off-by: Lisheng > Signed-off-by: Yisen Zhuang > Reviewed-by: Andy Shevchenko Applied.
Re: [PATCH v2 net-next] net: hns: add support of pause frame ctrl for HNS V2
From: Yisen Zhuang Date: Thu, 31 Mar 2016 21:00:09 +0800 > From: Lisheng > > The patch adds support of pause ctrl for HNS V2, and this feature is lost > by HNS V1: >1) service ports can disable rx pause frame, >2) debug ports can open tx/rx pause frame. > > And this patch updates the REGs about the pause ctrl when updated > status function called by upper layer routine. > > Signed-off-by: Lisheng > Signed-off-by: Yisen Zhuang > Reviewed-by: Andy Shevchenko Applied.
Re: [PATCH] netlink: use nla_get_in_addr and nla_put_in_addr for ipv4 address
From: Haishuang YanDate: Thu, 31 Mar 2016 18:21:38 +0800 > Since nla_get_in_addr and nla_put_in_addr were implemented, > so use them appropriately. > > Signed-off-by: Haishuang Yan Applied, thank you.
Re: [PATCH] netlink: use nla_get_in_addr and nla_put_in_addr for ipv4 address
From: Haishuang Yan Date: Thu, 31 Mar 2016 18:21:38 +0800 > Since nla_get_in_addr and nla_put_in_addr were implemented, > so use them appropriately. > > Signed-off-by: Haishuang Yan Applied, thank you.
Re: [PATCH 2/2] UBIFS: Implement ->migratepage()
Hi Kirill, [auto build test ERROR on v4.6-rc1] [also build test ERROR on next-20160401] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Richard-Weinberger/mm-Export-migrate_page_move_mapping-and-migrate_page_copy/20160401-060041 config: xtensa-audio_kc705_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=xtensa All errors (new ones prefixed by >>): fs/ubifs/file.c: In function 'ubifs_migrate_page': >> fs/ubifs/file.c:1461:2: error: implicit declaration of function >> 'migrate_page_move_mapping' [-Werror=implicit-function-declaration] rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0); ^ cc1: some warnings being treated as errors vim +/migrate_page_move_mapping +1461 fs/ubifs/file.c 1455 1456 static int ubifs_migrate_page(struct address_space *mapping, 1457 struct page *newpage, struct page *page, enum migrate_mode mode) 1458 { 1459 int rc; 1460 > 1461 rc = migrate_page_move_mapping(mapping, newpage, page, NULL, > mode, 0); 1462 if (rc != MIGRATEPAGE_SUCCESS) 1463 return rc; 1464 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH 2/2] UBIFS: Implement ->migratepage()
Hi Kirill, [auto build test ERROR on v4.6-rc1] [also build test ERROR on next-20160401] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Richard-Weinberger/mm-Export-migrate_page_move_mapping-and-migrate_page_copy/20160401-060041 config: xtensa-audio_kc705_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=xtensa All errors (new ones prefixed by >>): fs/ubifs/file.c: In function 'ubifs_migrate_page': >> fs/ubifs/file.c:1461:2: error: implicit declaration of function >> 'migrate_page_move_mapping' [-Werror=implicit-function-declaration] rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0); ^ cc1: some warnings being treated as errors vim +/migrate_page_move_mapping +1461 fs/ubifs/file.c 1455 1456 static int ubifs_migrate_page(struct address_space *mapping, 1457 struct page *newpage, struct page *page, enum migrate_mode mode) 1458 { 1459 int rc; 1460 > 1461 rc = migrate_page_move_mapping(mapping, newpage, page, NULL, > mode, 0); 1462 if (rc != MIGRATEPAGE_SUCCESS) 1463 return rc; 1464 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
{standard input}:116: Error: number (0x9000000080000000) larger than 32 bits
Hi Sasha, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 264800b5ecc7be49b2c6027738091ff3385e0cae commit: 71458cfc782eafe4b27656e078d379a34e472adf kernel: add support for gcc 5 date: 1 year, 6 months ago config: mips-allnoconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 71458cfc782eafe4b27656e078d379a34e472adf # save the attached .config to linux build tree make.cross ARCH=mips All errors (new ones prefixed by >>): {standard input}: Assembler messages: >> {standard input}:116: Error: number (0x90008000) larger than 32 bits {standard input}:150: Error: number (0x90008000) larger than 32 bits {standard input}:172: Error: number (0x90008000) larger than 32 bits --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
{standard input}:116: Error: number (0x9000000080000000) larger than 32 bits
Hi Sasha, FYI, the error/warning still remains. tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 264800b5ecc7be49b2c6027738091ff3385e0cae commit: 71458cfc782eafe4b27656e078d379a34e472adf kernel: add support for gcc 5 date: 1 year, 6 months ago config: mips-allnoconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 71458cfc782eafe4b27656e078d379a34e472adf # save the attached .config to linux build tree make.cross ARCH=mips All errors (new ones prefixed by >>): {standard input}: Assembler messages: >> {standard input}:116: Error: number (0x90008000) larger than 32 bits {standard input}:150: Error: number (0x90008000) larger than 32 bits {standard input}:172: Error: number (0x90008000) larger than 32 bits --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name 'rur.ae_ovf_sar'
Hi Max, First bad commit (maybe != root cause): tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 264800b5ecc7be49b2c6027738091ff3385e0cae commit: 9da8320bb97768e35f2e64fa7642015271d672eb xtensa: add test_kc705_hifi variant date: 2 weeks ago config: xtensa-audio_kc705_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 9da8320bb97768e35f2e64fa7642015271d672eb # save the attached .config to linux build tree make.cross ARCH=xtensa All errors (new ones prefixed by >>): arch/xtensa/kernel/coprocessor.S: Assembler messages: >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_ovf_sar' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_bithead' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_ts_fts_bu_bp' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_cw_sd_no' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_cbegin0' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_cend0' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' -- arch/xtensa/include/asm/initialize_mmu.h: Assembler messages: >> arch/xtensa/include/asm/initialize_mmu.h:55: Error: invalid register >> 'atomctl' for 'wsr' instruction vim +93 arch/xtensa/kernel/coprocessor.S c658eac6 Chris Zankel 2008-02-12 87 .else; \ c658eac6 Chris Zankel 2008-02-12 88 .long 0; \ c658eac6 Chris Zankel 2008-02-12 89 .endif; \ c658eac6 Chris Zankel 2008-02-12 90 .long THREAD_XTREGS_CP##x 5a0015d6 Chris Zankel 2005-06-23 91 c658eac6 Chris Zankel 2008-02-12 92 SAVE_CP_REGS(0) c658eac6 Chris Zankel 2008-02-12 @93 SAVE_CP_REGS(1) c658eac6 Chris Zankel 2008-02-12 94 SAVE_CP_REGS(2) c658eac6 Chris Zankel 2008-02-12 95 SAVE_CP_REGS(3) c658eac6 Chris Zankel 2008-02-12 96 SAVE_CP_REGS(4) c658eac6 Chris Zankel 2008-02-12 97 SAVE_CP_REGS(5) c658eac6 Chris Zankel 2008-02-12 98 SAVE_CP_REGS(6) c658eac6 Chris Zankel 2008-02-12 99 SAVE_CP_REGS(7) 5a0015d6 Chris Zankel 2005-06-23 100 c658eac6 Chris Zankel 2008-02-12 101 LOAD_CP_REGS(0) c658eac6 Chris Zankel 2008-02-12 @102 LOAD_CP_REGS(1) c658eac6 Chris Zankel 2008-02-12 103 LOAD_CP_REGS(2) c658eac6 Chris Zankel 2008-02-12 104 LOAD_CP_REGS(3) c658eac6 Chris Zankel 2008-02-12 105 LOAD_CP_REGS(4) :: The code at line 93 was first introduced by commit :: c658eac628aa8df040dfe614556d95e6da3a9ffb [XTENSA] Add support for configurable registers and coprocessors :: TO: Chris Zankel:: CC: Chris Zankel --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name 'rur.ae_ovf_sar'
Hi Max, First bad commit (maybe != root cause): tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 264800b5ecc7be49b2c6027738091ff3385e0cae commit: 9da8320bb97768e35f2e64fa7642015271d672eb xtensa: add test_kc705_hifi variant date: 2 weeks ago config: xtensa-audio_kc705_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 9da8320bb97768e35f2e64fa7642015271d672eb # save the attached .config to linux build tree make.cross ARCH=xtensa All errors (new ones prefixed by >>): arch/xtensa/kernel/coprocessor.S: Assembler messages: >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_ovf_sar' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_bithead' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_ts_fts_bu_bp' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_cw_sd_no' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_cbegin0' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'rur.ae_cend0' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' >> arch/xtensa/kernel/coprocessor.S:93: Error: unknown opcode or format name >> 'ae_s64.i' -- arch/xtensa/include/asm/initialize_mmu.h: Assembler messages: >> arch/xtensa/include/asm/initialize_mmu.h:55: Error: invalid register >> 'atomctl' for 'wsr' instruction vim +93 arch/xtensa/kernel/coprocessor.S c658eac6 Chris Zankel 2008-02-12 87 .else; \ c658eac6 Chris Zankel 2008-02-12 88 .long 0; \ c658eac6 Chris Zankel 2008-02-12 89 .endif; \ c658eac6 Chris Zankel 2008-02-12 90 .long THREAD_XTREGS_CP##x 5a0015d6 Chris Zankel 2005-06-23 91 c658eac6 Chris Zankel 2008-02-12 92 SAVE_CP_REGS(0) c658eac6 Chris Zankel 2008-02-12 @93 SAVE_CP_REGS(1) c658eac6 Chris Zankel 2008-02-12 94 SAVE_CP_REGS(2) c658eac6 Chris Zankel 2008-02-12 95 SAVE_CP_REGS(3) c658eac6 Chris Zankel 2008-02-12 96 SAVE_CP_REGS(4) c658eac6 Chris Zankel 2008-02-12 97 SAVE_CP_REGS(5) c658eac6 Chris Zankel 2008-02-12 98 SAVE_CP_REGS(6) c658eac6 Chris Zankel 2008-02-12 99 SAVE_CP_REGS(7) 5a0015d6 Chris Zankel 2005-06-23 100 c658eac6 Chris Zankel 2008-02-12 101 LOAD_CP_REGS(0) c658eac6 Chris Zankel 2008-02-12 @102 LOAD_CP_REGS(1) c658eac6 Chris Zankel 2008-02-12 103 LOAD_CP_REGS(2) c658eac6 Chris Zankel 2008-02-12 104 LOAD_CP_REGS(3) c658eac6 Chris Zankel 2008-02-12 105 LOAD_CP_REGS(4) :: The code at line 93 was first introduced by commit :: c658eac628aa8df040dfe614556d95e6da3a9ffb [XTENSA] Add support for configurable registers and coprocessors :: TO: Chris Zankel :: CC: Chris Zankel --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [RFC patch 4/7] futex: Add support for attached futexes
On Sat, Apr 02 2016, Thomas Gleixnerwrote: > The standard futex mechanism in the Linux kernel uses a global hash to store > transient state. Collisions on that hash can lead to performance degradation > and on real-time enabled kernels even to priority inversions. > > To guarantee futexes without collisions on the global kernel hash, we provide > a mechanism to attach to a futex. This creates futex private state which > avoids hash collisions and on NUMA systems also cross node memory access. Hi, A few minor comments inline below, and a question about the design: How is an application supposed to handle it when the kernel fails to achieve the no collision-goal? With any reasonable upper bound on the size of the local hash table (which of course has to be there, whether sysctl'ed or not), and regardless of the hashing scheme used, it seems inevitable that someone is going to get -ENOSPC when trying to attach. Moreover, since different threads can attach to different sets of futexes, one thread may succesfully attach to a futex, while another fails - the second thread is then permanently prevented from operating on that futex (?). Why not use some sort of tree instead? Or fall back to a traditional chained hash table once we're no longer allowed to increase the table size? Of course these have worse lookup performance, and maybe failing the attach in the rare case is better than penalizing the common case, but it would be nice to have some mention of this in the change log. Alternatively [this is not really thought through], maybe one could move the decision and the complexity to userspace: On succesful FUTEX_ATTACH, return an index into a small per-task array of struct futex_state*. On subsequent FUTEX_ATTACHED operations on that futex, userspace passes in this index somehow (either instead of uaddr, in which case the kernel array would have to include this in addition to the futex_state pointer, or by making uaddr actually point to a struct { int *futex_addr; int attach_idx; }, or...) Then each thread would have to maintain a (futex address => index) mapping, but that's more or less what the kernel otherwise has to do. > + > +static unsigned int hash_prime(unsigned int size) > +{ > + switch(size) { > + case 16: > + default: return 13; > + case 32: return 31; > + case 64: return 61; > + case 128: return 127; > + case 256: return 251; > + case 512: return 509; > + case 1024: return 1021; > + case 2048: return 2039; > + case 4096: return 4093; > + } > +} > + There should probably be some mention of TASK_CACHE_{BASE,MAX}_SIZE here so that anyone updating those would also look here, so we don't end up using 13 out of 8192 slots... BUILD_BUG_ON(TASK_CACHE_{BASE,MAX}_SIZE != {16,4096}) should do it. > +static struct futex_cache *futex_alloc_cache(int cache_size) > +{ > + struct futex_cache *tc; > + size_t size; > + > + /* Allocate a new task cache */ > + size = sizeof(*tc) + cache_size * sizeof(struct futex_cache_slot); > + tc = kzalloc_node(size, GFP_KERNEL, numa_node_id()); > + if (tc) { > + tc->hash_prime = hash_prime(cache_size); > + tc->cache_size = cache_size; > + } > + return tc; > +} > + > +static int > +futex_rehash_task_cache(struct futex_cache *tc, struct futex_cache *tcnew) > +{ > + unsigned long *newmap = tcnew->cache_map; > + unsigned int prime = tcnew->hash_prime; > + unsigned long *map = tc->cache_map; > + unsigned int size = tc->cache_size; > + unsigned int slot, newslot; > + > + slot = find_first_bit(map, size); > + for (; slot < size; slot = find_next_bit(map, size, slot + 1)) { > + newslot = hash_local_futex(tc->slots[slot].uaddr, prime); > + /* > + * Paranoia. Rehashing to a larger cache should not result in > + * collisions which did not exist in the small one. > + */ This doesn't sound right when you're doing mod prime hashing; two numbers can easily have the same remainder mod 31 while having distinct remainders mod 13. > + if (__test_and_set_bit(newslot, newmap)) > + return -ENOSPC; > + /* Copy uaddr and futex state pointer */ > + tcnew->slots[newslot] = tc->slots[slot]; > + } > + return 0; > +} > + > +/** > + * futex_get_task_cache_slot - Get a slot in the tasks local cache > + * > + * If the cache is not yet available it's allocated. If the existing cache is > + * too small the cache is extended. > + * > + * Returns a valid slot or an error code > + */ > +static int futex_get_task_cache_slot(u32 __user *uaddr) > +{ > + struct futex_cache *tcnew, *tc = current->futex_cache; > + unsigned int cache_size; > + int slot; > + > + /* First caller allocates the initial cache */ > + if (!tc) { > + tc = futex_alloc_cache(TASK_CACHE_BASE_SIZE); > + if
Re: [RFC patch 4/7] futex: Add support for attached futexes
On Sat, Apr 02 2016, Thomas Gleixner wrote: > The standard futex mechanism in the Linux kernel uses a global hash to store > transient state. Collisions on that hash can lead to performance degradation > and on real-time enabled kernels even to priority inversions. > > To guarantee futexes without collisions on the global kernel hash, we provide > a mechanism to attach to a futex. This creates futex private state which > avoids hash collisions and on NUMA systems also cross node memory access. Hi, A few minor comments inline below, and a question about the design: How is an application supposed to handle it when the kernel fails to achieve the no collision-goal? With any reasonable upper bound on the size of the local hash table (which of course has to be there, whether sysctl'ed or not), and regardless of the hashing scheme used, it seems inevitable that someone is going to get -ENOSPC when trying to attach. Moreover, since different threads can attach to different sets of futexes, one thread may succesfully attach to a futex, while another fails - the second thread is then permanently prevented from operating on that futex (?). Why not use some sort of tree instead? Or fall back to a traditional chained hash table once we're no longer allowed to increase the table size? Of course these have worse lookup performance, and maybe failing the attach in the rare case is better than penalizing the common case, but it would be nice to have some mention of this in the change log. Alternatively [this is not really thought through], maybe one could move the decision and the complexity to userspace: On succesful FUTEX_ATTACH, return an index into a small per-task array of struct futex_state*. On subsequent FUTEX_ATTACHED operations on that futex, userspace passes in this index somehow (either instead of uaddr, in which case the kernel array would have to include this in addition to the futex_state pointer, or by making uaddr actually point to a struct { int *futex_addr; int attach_idx; }, or...) Then each thread would have to maintain a (futex address => index) mapping, but that's more or less what the kernel otherwise has to do. > + > +static unsigned int hash_prime(unsigned int size) > +{ > + switch(size) { > + case 16: > + default: return 13; > + case 32: return 31; > + case 64: return 61; > + case 128: return 127; > + case 256: return 251; > + case 512: return 509; > + case 1024: return 1021; > + case 2048: return 2039; > + case 4096: return 4093; > + } > +} > + There should probably be some mention of TASK_CACHE_{BASE,MAX}_SIZE here so that anyone updating those would also look here, so we don't end up using 13 out of 8192 slots... BUILD_BUG_ON(TASK_CACHE_{BASE,MAX}_SIZE != {16,4096}) should do it. > +static struct futex_cache *futex_alloc_cache(int cache_size) > +{ > + struct futex_cache *tc; > + size_t size; > + > + /* Allocate a new task cache */ > + size = sizeof(*tc) + cache_size * sizeof(struct futex_cache_slot); > + tc = kzalloc_node(size, GFP_KERNEL, numa_node_id()); > + if (tc) { > + tc->hash_prime = hash_prime(cache_size); > + tc->cache_size = cache_size; > + } > + return tc; > +} > + > +static int > +futex_rehash_task_cache(struct futex_cache *tc, struct futex_cache *tcnew) > +{ > + unsigned long *newmap = tcnew->cache_map; > + unsigned int prime = tcnew->hash_prime; > + unsigned long *map = tc->cache_map; > + unsigned int size = tc->cache_size; > + unsigned int slot, newslot; > + > + slot = find_first_bit(map, size); > + for (; slot < size; slot = find_next_bit(map, size, slot + 1)) { > + newslot = hash_local_futex(tc->slots[slot].uaddr, prime); > + /* > + * Paranoia. Rehashing to a larger cache should not result in > + * collisions which did not exist in the small one. > + */ This doesn't sound right when you're doing mod prime hashing; two numbers can easily have the same remainder mod 31 while having distinct remainders mod 13. > + if (__test_and_set_bit(newslot, newmap)) > + return -ENOSPC; > + /* Copy uaddr and futex state pointer */ > + tcnew->slots[newslot] = tc->slots[slot]; > + } > + return 0; > +} > + > +/** > + * futex_get_task_cache_slot - Get a slot in the tasks local cache > + * > + * If the cache is not yet available it's allocated. If the existing cache is > + * too small the cache is extended. > + * > + * Returns a valid slot or an error code > + */ > +static int futex_get_task_cache_slot(u32 __user *uaddr) > +{ > + struct futex_cache *tcnew, *tc = current->futex_cache; > + unsigned int cache_size; > + int slot; > + > + /* First caller allocates the initial cache */ > + if (!tc) { > + tc = futex_alloc_cache(TASK_CACHE_BASE_SIZE); > + if (!tc) > +
RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Saturday, April 2, 2016 3:23 PM > To: KY Srinivasan> Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com; > jasow...@redhat.com > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > management. > > On Sat, Apr 02, 2016 at 11:10:38AM -0700, K. Y. Srinivasan wrote: > > Cleanup and mmio management. Also included is a patch > > to fix an issue in KVP. > > So these all are for 4.7-rc1? Jake's PCI driver made it into 4.6 and some of the patches in this series fix issues in the Hyper-V PCI pass-through driver. Is it possible for this series to go into 4.6. If not, 4.7-rc1 is fine. Regards, K. Y
RE: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio management.
> -Original Message- > From: Greg KH [mailto:gre...@linuxfoundation.org] > Sent: Saturday, April 2, 2016 3:23 PM > To: KY Srinivasan > Cc: linux-kernel@vger.kernel.org; de...@linuxdriverproject.org; > o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com; > jasow...@redhat.com > Subject: Re: [PATCH 0/6] Drivers: hv: vmbus: Cleanup and mmio > management. > > On Sat, Apr 02, 2016 at 11:10:38AM -0700, K. Y. Srinivasan wrote: > > Cleanup and mmio management. Also included is a patch > > to fix an issue in KVP. > > So these all are for 4.7-rc1? Jake's PCI driver made it into 4.6 and some of the patches in this series fix issues in the Hyper-V PCI pass-through driver. Is it possible for this series to go into 4.6. If not, 4.7-rc1 is fine. Regards, K. Y
RE: Staging: unisys/verisonic: Correct double unlock
> -Original Message- > From: Iban Rodriguez [mailto:iban.rodrig...@ono.com] > Sent: Saturday, April 02, 2016 1:47 PM > To: Kershner, David A; Greg Kroah-Hartman; Benjamin Romer; Sell, Timothy > C; Neil Horman > Cc: *S-Par-Maintainer; de...@driverdev.osuosl.org; linux- > ker...@vger.kernel.org; Iban Rodriguez > Subject: Staging: unisys/verisonic: Correct double unlock > > 'priv_lock' is unlocked twice. The first one is removed and > the function 'visornic_serverdown_complete' is now called with > 'priv_lock' locked because 'devdata' is modified inside. > > Signed-off-by: Iban Rodriguez> --- > drivers/staging/unisys/visornic/visornic_main.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/staging/unisys/visornic/visornic_main.c > b/drivers/staging/unisys/visornic/visornic_main.c > index be0d057346c3..af03f2938fe9 100644 > --- a/drivers/staging/unisys/visornic/visornic_main.c > +++ b/drivers/staging/unisys/visornic/visornic_main.c > @@ -368,7 +368,6 @@ visornic_serverdown(struct visornic_devdata > *devdata, > } > devdata->server_change_state = true; > devdata->server_down_complete_func = complete_func; > - spin_unlock_irqrestore(>priv_lock, flags); > visornic_serverdown_complete(devdata); > } else if (devdata->server_change_state) { > dev_dbg(>dev->device, "%s changing state\n", I agree there is a bug here involving priv_lock being unlocked twice, but this patch isn't the appropriate fix. Reason is, we can NOT call visornic_serverdown_complete() while holding a spinlock (which is what this patch would cause to occur) because visornic_serverdown_complete() might block when it calls rtnl_lock() in this code sequence (rtnl_lock() grabs a mutex): rtnl_lock(); dev_close(netdev); rtnl_unlock(); Blocking with a spinlock held is always a bad idea. :-( > -- > 1.9.1
RE: Staging: unisys/verisonic: Correct double unlock
> -Original Message- > From: Iban Rodriguez [mailto:iban.rodrig...@ono.com] > Sent: Saturday, April 02, 2016 1:47 PM > To: Kershner, David A; Greg Kroah-Hartman; Benjamin Romer; Sell, Timothy > C; Neil Horman > Cc: *S-Par-Maintainer; de...@driverdev.osuosl.org; linux- > ker...@vger.kernel.org; Iban Rodriguez > Subject: Staging: unisys/verisonic: Correct double unlock > > 'priv_lock' is unlocked twice. The first one is removed and > the function 'visornic_serverdown_complete' is now called with > 'priv_lock' locked because 'devdata' is modified inside. > > Signed-off-by: Iban Rodriguez > --- > drivers/staging/unisys/visornic/visornic_main.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/staging/unisys/visornic/visornic_main.c > b/drivers/staging/unisys/visornic/visornic_main.c > index be0d057346c3..af03f2938fe9 100644 > --- a/drivers/staging/unisys/visornic/visornic_main.c > +++ b/drivers/staging/unisys/visornic/visornic_main.c > @@ -368,7 +368,6 @@ visornic_serverdown(struct visornic_devdata > *devdata, > } > devdata->server_change_state = true; > devdata->server_down_complete_func = complete_func; > - spin_unlock_irqrestore(>priv_lock, flags); > visornic_serverdown_complete(devdata); > } else if (devdata->server_change_state) { > dev_dbg(>dev->device, "%s changing state\n", I agree there is a bug here involving priv_lock being unlocked twice, but this patch isn't the appropriate fix. Reason is, we can NOT call visornic_serverdown_complete() while holding a spinlock (which is what this patch would cause to occur) because visornic_serverdown_complete() might block when it calls rtnl_lock() in this code sequence (rtnl_lock() grabs a mutex): rtnl_lock(); dev_close(netdev); rtnl_unlock(); Blocking with a spinlock held is always a bad idea. :-( > -- > 1.9.1
[PATCH 1/6] Drivers: hv: vmbus: Introduce functions for estimating room in the ring buffer
Introduce separate functions for estimating how much can be read from and written to the ring buffer. Signed-off-by: K. Y. Srinivasan--- drivers/hv/ring_buffer.c | 25 - include/linux/hyperv.h | 27 +++ 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index a40a73a..544362c 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -38,8 +38,6 @@ void hv_begin_read(struct hv_ring_buffer_info *rbi) u32 hv_end_read(struct hv_ring_buffer_info *rbi) { - u32 read; - u32 write; rbi->ring_buffer->interrupt_mask = 0; mb(); @@ -49,9 +47,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi) * If it is not, we raced and we need to process new * incoming messages. */ - hv_get_ringbuffer_availbytes(rbi, , ); - - return read; + return hv_get_bytes_to_read(rbi); } /* @@ -106,9 +102,6 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) { u32 cur_write_sz; - u32 r_size; - u32 write_loc; - u32 read_loc = rbi->ring_buffer->read_index; u32 pending_sz; /* @@ -125,14 +118,11 @@ static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) mb(); pending_sz = rbi->ring_buffer->pending_send_sz; - write_loc = rbi->ring_buffer->write_index; /* If the other end is not blocked on write don't bother. */ if (pending_sz == 0) return false; - r_size = rbi->ring_datasize; - cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) : - read_loc - write_loc; + cur_write_sz = hv_get_bytes_to_write(rbi); if (cur_write_sz >= pending_sz) return true; @@ -332,7 +322,6 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, { int i = 0; u32 bytes_avail_towrite; - u32 bytes_avail_toread; u32 totalbytes_towrite = 0; u32 next_write_location; @@ -348,9 +337,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, if (lock) spin_lock_irqsave(_info->ring_lock, flags); - hv_get_ringbuffer_availbytes(outring_info, - _avail_toread, - _avail_towrite); + bytes_avail_towrite = hv_get_bytes_to_write(outring_info); /* * If there is only room for the packet, assume it is full. @@ -401,7 +388,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer, u32 buflen, u32 *buffer_actual_len, u64 *requestid, bool *signal, bool raw) { - u32 bytes_avail_towrite; u32 bytes_avail_toread; u32 next_read_location = 0; u64 prev_indices = 0; @@ -417,10 +403,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, *buffer_actual_len = 0; *requestid = 0; - hv_get_ringbuffer_availbytes(inring_info, - _avail_toread, - _avail_towrite); - + bytes_avail_toread = hv_get_bytes_to_read(inring_info); /* Make sure there is something to read */ if (bytes_avail_toread < sizeof(desc)) { /* diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index ecd81c3..a6b053c 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -151,6 +151,33 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi, *read = dsize - *write; } +static inline u32 hv_get_bytes_to_read(struct hv_ring_buffer_info *rbi) +{ + u32 read_loc, write_loc, dsize, read; + + dsize = rbi->ring_datasize; + read_loc = rbi->ring_buffer->read_index; + write_loc = READ_ONCE(rbi->ring_buffer->write_index); + + read = write_loc >= read_loc ? (write_loc - read_loc) : + (dsize - read_loc) + write_loc; + + return read; +} + +static inline u32 hv_get_bytes_to_write(struct hv_ring_buffer_info *rbi) +{ + u32 read_loc, write_loc, dsize, write; + + dsize = rbi->ring_datasize; + read_loc = READ_ONCE(rbi->ring_buffer->read_index); + write_loc = rbi->ring_buffer->write_index; + + write = write_loc >= read_loc ? dsize - (write_loc - read_loc) : + read_loc - write_loc; + return write; +} + /* * VMBUS version is 32 bit entity broken up into * two 16 bit quantities: major_number. minor_number. -- 1.7.4.1
[PATCH 4/6] Drivers: hv: vmbus: Export the vmbus_set_event() API
In preparation for moving some ring buffer functionality out of the vmbus driver, export the API for signaling the host. Signed-off-by: K. Y. Srinivasan--- drivers/hv/connection.c |1 + drivers/hv/hyperv_vmbus.h |2 -- include/linux/hyperv.h|1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index d02f137..fcf8a02 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -495,3 +495,4 @@ void vmbus_set_event(struct vmbus_channel *channel) hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL); } +EXPORT_SYMBOL_GPL(vmbus_set_event); diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 8b07f9c..e5203e4 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -672,8 +672,6 @@ void vmbus_disconnect(void); int vmbus_post_msg(void *buffer, size_t buflen); -void vmbus_set_event(struct vmbus_channel *channel); - void vmbus_on_event(unsigned long data); void vmbus_on_msg_dpc(unsigned long data); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index a6b053c..4adeb6e 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1365,4 +1365,5 @@ extern __u32 vmbus_proto_version; int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, const uuid_le *shv_host_servie_id); +void vmbus_set_event(struct vmbus_channel *channel); #endif /* _HYPERV_H */ -- 1.7.4.1
[PATCH 1/6] Drivers: hv: vmbus: Introduce functions for estimating room in the ring buffer
Introduce separate functions for estimating how much can be read from and written to the ring buffer. Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c | 25 - include/linux/hyperv.h | 27 +++ 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index a40a73a..544362c 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -38,8 +38,6 @@ void hv_begin_read(struct hv_ring_buffer_info *rbi) u32 hv_end_read(struct hv_ring_buffer_info *rbi) { - u32 read; - u32 write; rbi->ring_buffer->interrupt_mask = 0; mb(); @@ -49,9 +47,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi) * If it is not, we raced and we need to process new * incoming messages. */ - hv_get_ringbuffer_availbytes(rbi, , ); - - return read; + return hv_get_bytes_to_read(rbi); } /* @@ -106,9 +102,6 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) { u32 cur_write_sz; - u32 r_size; - u32 write_loc; - u32 read_loc = rbi->ring_buffer->read_index; u32 pending_sz; /* @@ -125,14 +118,11 @@ static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) mb(); pending_sz = rbi->ring_buffer->pending_send_sz; - write_loc = rbi->ring_buffer->write_index; /* If the other end is not blocked on write don't bother. */ if (pending_sz == 0) return false; - r_size = rbi->ring_datasize; - cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) : - read_loc - write_loc; + cur_write_sz = hv_get_bytes_to_write(rbi); if (cur_write_sz >= pending_sz) return true; @@ -332,7 +322,6 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, { int i = 0; u32 bytes_avail_towrite; - u32 bytes_avail_toread; u32 totalbytes_towrite = 0; u32 next_write_location; @@ -348,9 +337,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info, if (lock) spin_lock_irqsave(_info->ring_lock, flags); - hv_get_ringbuffer_availbytes(outring_info, - _avail_toread, - _avail_towrite); + bytes_avail_towrite = hv_get_bytes_to_write(outring_info); /* * If there is only room for the packet, assume it is full. @@ -401,7 +388,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer, u32 buflen, u32 *buffer_actual_len, u64 *requestid, bool *signal, bool raw) { - u32 bytes_avail_towrite; u32 bytes_avail_toread; u32 next_read_location = 0; u64 prev_indices = 0; @@ -417,10 +403,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, *buffer_actual_len = 0; *requestid = 0; - hv_get_ringbuffer_availbytes(inring_info, - _avail_toread, - _avail_towrite); - + bytes_avail_toread = hv_get_bytes_to_read(inring_info); /* Make sure there is something to read */ if (bytes_avail_toread < sizeof(desc)) { /* diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index ecd81c3..a6b053c 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -151,6 +151,33 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi, *read = dsize - *write; } +static inline u32 hv_get_bytes_to_read(struct hv_ring_buffer_info *rbi) +{ + u32 read_loc, write_loc, dsize, read; + + dsize = rbi->ring_datasize; + read_loc = rbi->ring_buffer->read_index; + write_loc = READ_ONCE(rbi->ring_buffer->write_index); + + read = write_loc >= read_loc ? (write_loc - read_loc) : + (dsize - read_loc) + write_loc; + + return read; +} + +static inline u32 hv_get_bytes_to_write(struct hv_ring_buffer_info *rbi) +{ + u32 read_loc, write_loc, dsize, write; + + dsize = rbi->ring_datasize; + read_loc = READ_ONCE(rbi->ring_buffer->read_index); + write_loc = rbi->ring_buffer->write_index; + + write = write_loc >= read_loc ? dsize - (write_loc - read_loc) : + read_loc - write_loc; + return write; +} + /* * VMBUS version is 32 bit entity broken up into * two 16 bit quantities: major_number. minor_number. -- 1.7.4.1
[PATCH 4/6] Drivers: hv: vmbus: Export the vmbus_set_event() API
In preparation for moving some ring buffer functionality out of the vmbus driver, export the API for signaling the host. Signed-off-by: K. Y. Srinivasan --- drivers/hv/connection.c |1 + drivers/hv/hyperv_vmbus.h |2 -- include/linux/hyperv.h|1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index d02f137..fcf8a02 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -495,3 +495,4 @@ void vmbus_set_event(struct vmbus_channel *channel) hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL); } +EXPORT_SYMBOL_GPL(vmbus_set_event); diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 8b07f9c..e5203e4 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -672,8 +672,6 @@ void vmbus_disconnect(void); int vmbus_post_msg(void *buffer, size_t buflen); -void vmbus_set_event(struct vmbus_channel *channel); - void vmbus_on_event(unsigned long data); void vmbus_on_msg_dpc(unsigned long data); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index a6b053c..4adeb6e 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1365,4 +1365,5 @@ extern __u32 vmbus_proto_version; int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, const uuid_le *shv_host_servie_id); +void vmbus_set_event(struct vmbus_channel *channel); #endif /* _HYPERV_H */ -- 1.7.4.1
[PATCH 5/6] Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h
In preparation for implementing APIs for in-place consumption of VMBUS packets, movve some ring buffer functionality into hyperv.h Signed-off-by: K. Y. Srinivasan--- drivers/hv/ring_buffer.c | 55 -- include/linux/hyperv.h | 54 + 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 8f518af..dd255c9 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -84,52 +84,6 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) return false; } -/* - * To optimize the flow management on the send-side, - * when the sender is blocked because of lack of - * sufficient space in the ring buffer, potential the - * consumer of the ring buffer can signal the producer. - * This is controlled by the following parameters: - * - * 1. pending_send_sz: This is the size in bytes that the - *producer is trying to send. - * 2. The feature bit feat_pending_send_sz set to indicate if - *the consumer of the ring will signal when the ring - *state transitions from being full to a state where - *there is room for the producer to send the pending packet. - */ - -static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) -{ - u32 cur_write_sz; - u32 pending_sz; - - /* -* Issue a full memory barrier before making the signaling decision. -* Here is the reason for having this barrier: -* If the reading of the pend_sz (in this function) -* were to be reordered and read before we commit the new read -* index (in the calling function) we could -* have a problem. If the host were to set the pending_sz after we -* have sampled pending_sz and go to sleep before we commit the -* read index, we could miss sending the interrupt. Issue a full -* memory barrier to address this. -*/ - virt_mb(); - - pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); - /* If the other end is not blocked on write don't bother. */ - if (pending_sz == 0) - return false; - - cur_write_sz = hv_get_bytes_to_write(rbi); - - if (cur_write_sz >= pending_sz) - return true; - - return false; -} - /* Get the next write location for the specified ring buffer. */ static inline u32 hv_get_next_write_location(struct hv_ring_buffer_info *ring_info) @@ -180,15 +134,6 @@ hv_set_next_read_location(struct hv_ring_buffer_info *ring_info, ring_info->ring_buffer->read_index = next_read_location; } - -/* Get the start of the ring buffer. */ -static inline void * -hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info) -{ - return (void *)ring_info->ring_buffer->buffer; -} - - /* Get the size of the ring buffer. */ static inline u32 hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 4adeb6e..6797a30 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1366,4 +1366,58 @@ extern __u32 vmbus_proto_version; int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, const uuid_le *shv_host_servie_id); void vmbus_set_event(struct vmbus_channel *channel); + +/* Get the start of the ring buffer. */ +static inline void * +hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info) +{ + return (void *)ring_info->ring_buffer->buffer; +} + +/* + * To optimize the flow management on the send-side, + * when the sender is blocked because of lack of + * sufficient space in the ring buffer, potential the + * consumer of the ring buffer can signal the producer. + * This is controlled by the following parameters: + * + * 1. pending_send_sz: This is the size in bytes that the + *producer is trying to send. + * 2. The feature bit feat_pending_send_sz set to indicate if + *the consumer of the ring will signal when the ring + *state transitions from being full to a state where + *there is room for the producer to send the pending packet. + */ + +static inline bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) +{ + u32 cur_write_sz; + u32 pending_sz; + + /* +* Issue a full memory barrier before making the signaling decision. +* Here is the reason for having this barrier: +* If the reading of the pend_sz (in this function) +* were to be reordered and read before we commit the new read +* index (in the calling function) we could +* have a problem. If the host were to set the pending_sz after we +* have sampled pending_sz and go to sleep before we commit the +* read index, we could miss sending the interrupt. Issue a full +* memory barrier to address this. +*/ + virt_mb(); + +
[PATCH 6/6] Drivers: hv: vmbus: Implement APIs to support "in place" consumption of vmbus packets
Implement APIs for in-place consumption of vmbus packets. Currently, each packet is copied and processed one at a time and as part of processing each packet we potentially may signal the host (if it is waiting for room to produce a packet). These APIs help batched in-place processing of vmbus packets. We also optimize host signaling by having a separate API to signal the end of in-place consumption. With netvsc using these APIs, on an iperf run on average I see about 20X reduction in checks to signal the host. Signed-off-by: K. Y. Srinivasan--- drivers/hv/ring_buffer.c |1 + include/linux/hyperv.h | 86 ++ 2 files changed, 87 insertions(+), 0 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index dd255c9..fe586bf 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -132,6 +132,7 @@ hv_set_next_read_location(struct hv_ring_buffer_info *ring_info, u32 next_read_location) { ring_info->ring_buffer->read_index = next_read_location; + ring_info->priv_read_index = next_read_location; } /* Get the size of the ring buffer. */ diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 6797a30..b10954a 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -126,6 +126,8 @@ struct hv_ring_buffer_info { u32 ring_datasize; /* < ring_size */ u32 ring_data_startoffset; + u32 priv_write_index; + u32 priv_read_index; }; /* @@ -1420,4 +1422,88 @@ static inline bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) return false; } +/* + * An API to support in-place processing of incoming VMBUS packets. + */ +#define VMBUS_PKT_TRAILER 8 + +static inline struct vmpacket_descriptor * +get_next_pkt_raw(struct vmbus_channel *channel) +{ + struct hv_ring_buffer_info *ring_info = >inbound; + u32 read_loc = ring_info->priv_read_index; + void *ring_buffer = hv_get_ring_buffer(ring_info); + struct vmpacket_descriptor *cur_desc; + u32 packetlen; + u32 dsize = ring_info->ring_datasize; + u32 delta = read_loc - ring_info->ring_buffer->read_index; + u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta); + + if (bytes_avail_toread < sizeof(struct vmpacket_descriptor)) + return NULL; + + if ((read_loc + sizeof(*cur_desc)) > dsize) + return NULL; + + cur_desc = ring_buffer + read_loc; + packetlen = cur_desc->len8 << 3; + + /* +* If the packet under consideration is wrapping around, +* return failure. +*/ + if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1)) + return NULL; + + return cur_desc; +} + +/* + * A helper function to step through packets "in-place" + * This API is to be called after each successful call + * get_next_pkt_raw(). + */ +static inline void put_pkt_raw(struct vmbus_channel *channel, + struct vmpacket_descriptor *desc) +{ + struct hv_ring_buffer_info *ring_info = >inbound; + u32 read_loc = ring_info->priv_read_index; + u32 packetlen = desc->len8 << 3; + u32 dsize = ring_info->ring_datasize; + + if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize) + BUG(); + /* +* Include the packet trailer. +*/ + ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER; +} + +/* + * This call commits the read index and potentially signals the host. + * Here is the pattern for using the "in-place" consumption APIs: + * + * while (get_next_pkt_raw() { + * process the packet "in-place"; + * put_pkt_raw(); + * } + * if (packets processed in place) + * commit_rd_index(); + */ +static inline void commit_rd_index(struct vmbus_channel *channel) +{ + struct hv_ring_buffer_info *ring_info = >inbound; + /* +* Make sure all reads are done before we update the read index since +* the writer may start writing to the read area once the read index +* is updated. +*/ + virt_rmb(); + ring_info->ring_buffer->read_index = ring_info->priv_read_index; + + if (hv_need_to_signal_on_read(ring_info)) + vmbus_set_event(channel); +} + + #endif /* _HYPERV_H */ -- 1.7.4.1